AvaloniaList<T> Class
Definition
A notifying list.
public class AvaloniaList<T>
Remarks
AvaloniaList is similar to System.Collections.ObjectModel.ObservableCollection<T> with a few added features:
- It can be configured to notify the Avalonia.Collections.AvaloniaList<T>.CollectionChanged event with a System.Collections.Specialized.NotifyCollectionChangedAction.Remove action instead of a System.Collections.Specialized.NotifyCollectionChangedAction.Reset when the list is cleared by setting Avalonia.Collections.AvaloniaList<T>.ResetBehavior to Avalonia.Collections.ResetBehavior.Remove.
- A Avalonia.Collections.AvaloniaList<T>.Validate function can be used to validate each item before insertion.
Constructors
| Name | Description |
|---|---|
| AvaloniaList<T> (4 overloads) | Initializes a new instance of the Avalonia.Collections.AvaloniaList<T> class. |
AvaloniaList<T> overloads
AvaloniaList<T> Constructor
Initializes a new instance of the Avalonia.Collections.AvaloniaList<T> class.
public AvaloniaList<T>()
AvaloniaList<T> Constructor
public AvaloniaList<T>(System.Collections.Generic.IEnumerable<T> items)
Parameters
items System.Collections.Generic.IEnumerable<T>
AvaloniaList<T> Constructor
Initializes a new instance of the Avalonia.Collections.AvaloniaList<T>.
public AvaloniaList<T>(int capacity)
Parameters
capacity int
Initial list capacity.
AvaloniaList<T> Constructor
Initializes a new instance of the Avalonia.Collections.AvaloniaList<T> class.
public AvaloniaList<T>(T[] items)
Parameters
items T[]
The initial items for the collection.
Methods
| Name | Description |
|---|---|
| Add | Adds an item to the collection. |
| AddRange | No summary available. |
| Clear | Removes all items from the collection. |
| Contains | Tests if the collection contains the specified item. |
| CopyTo | Copies the collection's contents to an array. |
| EnsureCapacity | Ensures that the capacity of the list is at least Avalonia.Collections.AvaloniaList<T>.Capacity. |
| GetEnumerator | No summary available. |
| GetRange | Gets a range of items from the collection. |
| IndexOf | Gets the index of the specified item in the collection. |
| Insert | Inserts an item at the specified index. |
| InsertRange | No summary available. |
| Move | Moves an item to a new index. |
| MoveRange | Moves multiple items to a new index. |
| Remove | Removes an item from the collection. |
| RemoveAll | No summary available. |
| RemoveAt | Removes the item at the specified index. |
| RemoveRange | Removes a range of elements from the collection. |
Add Method
Adds an item to the collection.
public void Add(T item)
Parameters
item T
The item.
AddRange Method
public void AddRange(System.Collections.Generic.IEnumerable<T> items)
Parameters
items System.Collections.Generic.IEnumerable<T>
Clear Method
Removes all items from the collection.
public void Clear()
Contains Method
Tests if the collection contains the specified item.
public bool Contains(T item)
Parameters
item T
The item.
Returns
bool
True if the collection contains the item; otherwise false.
CopyTo Method
Copies the collection's contents to an array.
public void CopyTo(T[] array, int arrayIndex)
Parameters
array T[]
The array.
arrayIndex int
The first index of the array to copy to.
EnsureCapacity Method
Ensures that the capacity of the list is at least Avalonia.Collections.AvaloniaList<T>.Capacity.
public void EnsureCapacity(int capacity)
Parameters
capacity int
The capacity.
GetEnumerator Method
public Avalonia.Collections.AvaloniaList<T>.Enumerator<T><T> GetEnumerator()
Returns
Avalonia.Collections.AvaloniaList<T>.Enumerator<T><T>
GetRange Method
Gets a range of items from the collection.
public System.Collections.Generic.IEnumerable<T> GetRange(int index, int count)
Parameters
index int
The zero-based Avalonia.Collections.AvaloniaList<T> index at which the range starts.
count int
The number of elements in the range.
Returns
System.Collections.Generic.IEnumerable<T>
IndexOf Method
Gets the index of the specified item in the collection.
public int IndexOf(T item)
Parameters
item T
The item.
Returns
int
The index of the item or -1 if the item is not contained in the collection.
Insert Method
Inserts an item at the specified index.
public void Insert(int index, T item)
Parameters
index int
The index.
item T
The item.
InsertRange Method
public void InsertRange(int index, System.Collections.Generic.IEnumerable<T> items)
Parameters
index int
items System.Collections.Generic.IEnumerable<T>
Move Method
Moves an item to a new index.
public void Move(int oldIndex, int newIndex)
Parameters
oldIndex int
The index of the item to move.
newIndex int
The index to move the item to.
MoveRange Method
Moves multiple items to a new index.
public void MoveRange(int oldIndex, int count, int newIndex)
Parameters
oldIndex int
The first index of the items to move.
count int
The number of items to move.
newIndex int
The index to move the items to.
Remove Method
Removes an item from the collection.
public bool Remove(T item)
Parameters
item T
The item.
Returns
bool
True if the item was found and removed, otherwise false.
RemoveAll Method
public void RemoveAll(System.Collections.Generic.IEnumerable<T> items)
Parameters
items System.Collections.Generic.IEnumerable<T>
RemoveAt Method
Removes the item at the specified index.
public void RemoveAt(int index)
Parameters
index int
The index.
RemoveRange Method
Removes a range of elements from the collection.
public void RemoveRange(int index, int count)
Parameters
index int
The first index to remove.
count int
The number of items to remove.
Properties
| Name | Description |
|---|---|
| Capacity | Gets or sets the total number of elements the internal data structure can hold without resizing. |
| Count | Gets the number of items in the collection. |
| Item | No summary available. |
| ResetBehavior | Gets or sets the reset behavior of the list. |
| Validate | Gets or sets a validation routine that can be used to validate items before they are added. |
Capacity Property
Gets or sets the total number of elements the internal data structure can hold without resizing.
public int Capacity { get; set; }
Count Property
Gets the number of items in the collection.
public int Count { get; set; }
Item Property
public T Item { get; set; }
ResetBehavior Property
Gets or sets the reset behavior of the list.
public Avalonia.Collections.ResetBehavior ResetBehavior { get; set; }
Validate Property
Gets or sets a validation routine that can be used to validate items before they are added.
public Action<T> Validate { get; set; }
Events
| Name | Description |
|---|---|
| CollectionChanged | Raised when a change is made to the collection's items. |
| PropertyChanged | Raised when a property on the collection changes. |
CollectionChanged Event
Raised when a change is made to the collection's items.
public event System.Collections.Specialized.NotifyCollectionChangedEventHandler CollectionChanged
PropertyChanged Event
Raised when a property on the collection changes.
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged