Skip to main content

AvaloniaList<T> Class

Definition​

Assembly:Avalonia.Base
Package:Avalonia

A notifying list.

public class AvaloniaList<T>

Inheritance: object -> AvaloniaList<T>

Implements: IAvaloniaList<>, IAvaloniaReadOnlyList<>, INotifyCollectionChangedDebug, ICollection<>, IEnumerable<>, IList<>, IReadOnlyCollection<>, IReadOnlyList<>, ICollection, IEnumerable, IList, INotifyCollectionChanged, INotifyPropertyChanged

Remarks​

AvaloniaList is similar to System.Collections.ObjectModel.ObservableCollection<T> with a few added features:

Constructors​

NameDescription
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​

NameDescription
AddAdds an item to the collection.
AddRangeNo summary available.
ClearRemoves all items from the collection.
ContainsTests if the collection contains the specified item.
CopyToCopies the collection's contents to an array.
EnsureCapacityEnsures that the capacity of the list is at least Avalonia.Collections.AvaloniaList<T>.Capacity.
GetEnumeratorNo summary available.
GetRangeGets a range of items from the collection.
IndexOfGets the index of the specified item in the collection.
InsertInserts an item at the specified index.
InsertRangeNo summary available.
MoveMoves an item to a new index.
MoveRangeMoves multiple items to a new index.
RemoveRemoves an item from the collection.
RemoveAllNo summary available.
RemoveAtRemoves the item at the specified index.
RemoveRangeRemoves 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​

NameDescription
CapacityGets or sets the total number of elements the internal data structure can hold without resizing.
CountGets the number of items in the collection.
ItemNo summary available.
ResetBehaviorGets or sets the reset behavior of the list.
ValidateGets 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​

NameDescription
CollectionChangedRaised when a change is made to the collection's items.
PropertyChangedRaised 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