Table of Contents

Class ItemCollection

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll

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

public class ItemCollection : ItemsSourceView, IReadOnlyList<object?>, IReadOnlyCollection<object?>, IEnumerable<object?>, INotifyCollectionChanged, IList, ICollection, IEnumerable
Inheritance
ItemCollection
Implements
Inherited Members

Properties

IsReadOnly

public bool IsReadOnly { get; }

Property Value

bool

this[int]

public object? this[int index] { get; set; }

Parameters

index int

Property Value

object

Methods

Add(object?)

Adds an item to the 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

InvalidOperationException

The collection is in ItemsSource mode.

Clear()

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

public void Clear()

Exceptions

InvalidOperationException

The collection is in ItemsSource mode.

Insert(int, object?)

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

InvalidOperationException

The collection is in ItemsSource mode.

Remove(object?)

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

InvalidOperationException

The collection is in ItemsSource mode.

RemoveAt(int)

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

InvalidOperationException

The collection is in ItemsSource mode.