Skip to main content

ItemCollection Class

Definition

Assembly:Avalonia.Controls
Package:Avalonia

Holds the list of items that constitute the content of an Avalonia.Controls.ItemsControl.

public class ItemCollection

Inheritance: object -> ItemsSourceView -> ItemCollection

Implements: ICollection, IEnumerable, IList

Methods

NameDescription
AddAdds an item to the Avalonia.Controls.ItemsControl.
ClearClears the collection and releases the references on all items currently in the collection.
InsertInserts an element into the collection at the specified index.
RemoveRemoves the specified item reference from the collection or view.
RemoveAtRemoves the item at the specified index of the collection or view.
ContainsInherited from ItemsSourceView.
GetAtRetrieves the item at the specified index. Inherited from ItemsSourceView.
GetEnumeratorInherited from ItemsSourceView.
GetOrCreate (2 overloads)Inherited from ItemsSourceView.
IndexOfInherited from ItemsSourceView.

Add Method

Adds an item to the Avalonia.Controls.ItemsControl.

public int Add(object value)

Parameters

value object

The item to add to the collection.

Returns

int

The position into which the new element was inserted, or -1 to indicate that the item was not inserted into the collection.

Exceptions

Clear Method

Clears the collection and releases the references on all items currently in the collection.

public void Clear()

Exceptions

Insert Method

Inserts an element into the collection at the specified index.

public void Insert(int index, object value)

Parameters

index int

The zero-based index at which to insert the item.

value object

The item to insert.

Exceptions

Remove Method

Removes the specified item reference from the collection or view.

public bool Remove(object value)

Parameters

value object

The object to remove.

Returns

bool

True if the item was removed; otherwise false.

Exceptions

RemoveAt Method

Removes the item at the specified index of the collection or view.

public void RemoveAt(int index)

Parameters

index int

The zero-based index of the item to remove.

Exceptions

Properties

NameDescription
IsReadOnlyNo summary available.
ItemNo summary available.
CountGets the number of items in the collection. Inherited from ItemsSourceView.
EmptyGets an empty Avalonia.Controls.ItemsSourceView Inherited from ItemsSourceView.
SourceGets the source collection. Inherited from ItemsSourceView.

IsReadOnly Property

public bool IsReadOnly { get; set; }

Item Property

public object Item { get; set; }

Events

NameDescription
CollectionChangedOccurs when the collection has changed to indicate the reason for the change and which items changed. Inherited from ItemsSourceView.