Class ItemCollection
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
this[int]
public object? this[int index] { get; set; }
Parameters
index
int
Property Value
Methods
Add(object?)
Adds an item to the ItemsControl.
public int Add(object? value)
Parameters
value
objectThe 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
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
objectThe 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
intThe zero-based index of the item to remove.
Exceptions
- InvalidOperationException
The collection is in ItemsSource mode.