AvaloniaList<T> Class

Summary

A notifying list.
Namespace
Avalonia.Collections
Interfaces
Base Types
  • object
Derived Types
graph BT Type-->Base0["object"] Type-.->Interface0["IAvaloniaList<T>"] Type-.->Interface1["IList<T>"] Type-.->Interface2["ICollection<T>"] Type-.->Interface3["IAvaloniaReadOnlyList<T>"] Type-.->Interface4["IReadOnlyList<T>"] Type-.->Interface5["IReadOnlyCollection<T>"] Type-.->Interface6["IEnumerable<T>"] Type-.->Interface7["INotifyCollectionChanged"] Type-.->Interface8["INotifyPropertyChanged"] Type-.->Interface9["IList"] Type-.->Interface10["ICollection"] Type-.->Interface11["IEnumerable"] Type-.->Interface12["INotifyCollectionChangedDebug"] click Interface12 "/api/Avalonia.Diagnostics/INotifyCollectionChangedDebug" Type["AvaloniaList<T>"] class Type type-node Derived0["TextDecorationCollection"]-->Type click Derived0 "/api/Avalonia.Media/TextDecorationCollection" Derived1["Transforms"]-->Type click Derived1 "/api/Avalonia.Media/Transforms" Derived2["KeyFrames"]-->Type click Derived2 "/api/Avalonia.Animation/KeyFrames" Derived3["DataGridSortDescriptionCollection"]-->Type click Derived3 "/api/Avalonia.Collections/DataGridSortDescriptionCollection" Derived4["Animator<T>"]-->Type click Derived4 "/api/Avalonia.Animation.Animators/Animator_1" Derived5["DefinitionList<T>"]-->Type click Derived5 "/api/Avalonia.Controls/DefinitionList_1" Derived6["Classes"]-->Type click Derived6 "/api/Avalonia.Controls/Classes" Derived7["Points"]-->Type click Derived7 "/api/Avalonia/Points" Derived8["GradientStops"]-->Type click Derived8 "/api/Avalonia.Media/GradientStops" Derived9["Transitions"]-->Type click Derived9 "/api/Avalonia.Animation/Transitions" Derived10["PathSegments"]-->Type click Derived10 "/api/Avalonia.Media/PathSegments" Derived11["DataTemplates"]-->Type click Derived11 "/api/Avalonia.Controls.Templates/DataTemplates" Derived12["Controls"]-->Type click Derived12 "/api/Avalonia.Controls/Controls" Derived13["PathFigures"]-->Type click Derived13 "/api/Avalonia.Media/PathFigures"

Syntax

public class AvaloniaList<T> : IAvaloniaList<T>, IList<T>, ICollection<T>, 
    IAvaloniaReadOnlyList<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, 
    INotifyCollectionChanged, INotifyPropertyChanged, IList, ICollection, IEnumerable, 
    INotifyCollectionChangedDebug

Remarks

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

  • It can be configured to notify the event with a action instead of a when the list is cleared by setting to . removed
  • A function can be used to validate each item before insertion. removed

Type Parameters

Name Description
T The type of the list items.

Constructors

Name Summary
AvaloniaList() Initializes a new instance of the AvaloniaList<T> class.
AvaloniaList(IEnumerable<T>) Initializes a new instance of the AvaloniaList<T> class.
AvaloniaList(int) Initializes a new instance of the AvaloniaList<T>.
AvaloniaList(T[]) Initializes a new instance of the AvaloniaList<T> class.

Events

Name Type Summary
CollectionChanged NotifyCollectionChangedEventHandler
Raised when a change is made to the collection's items.
PropertyChanged PropertyChangedEventHandler
Raised when a property on the collection changes.

Properties

Name Value Summary
Capacity int
Gets or sets the total number of elements the internal data structure can hold without resizing.
Count int
Gets the number of items in the collection.
ResetBehavior ResetBehavior
Gets or sets the reset behavior of the list.
this[int] T
Gets or sets the item at the specified index.
Validate Action<T>
Gets or sets a validation routine that can be used to validate items before they are added.

Methods

Name Value Summary
Add(T) void
Adds an item to the collection.
AddRange(IEnumerable<T>) void
Adds multiple items to the collection.
Clear() void
Removes all items from the collection.
Contains(T) bool
Tests if the collection contains the specified item.
CopyTo(T[], int) void
Copies the collection's contents to an array.
GetEnumerator() AvaloniaList<T>.Enumerator
GetRange(int, int) IEnumerable<T>
Gets a range of items from the collection.
IndexOf(T) int
Gets the index of the specified item in the collection.
Insert(int, T) void
Inserts an item at the specified index.
InsertRange(int, IEnumerable<T>) void
Inserts multiple items at the specified index.
Move(int, int) void
Moves an item to a new index.
MoveRange(int, int, int) void
Moves multiple items to a new index.
Remove(T) bool
Removes an item from the collection.
RemoveAll(IEnumerable<T>) void
Removes multiple items from the collection.
RemoveAt(int) void
Removes the item at the specified index.
RemoveRange(int, int) void
Removes a range of elements from the collection.

Extension Methods

Name Value Summary
CreateDerivedList<T, TDerived>(Func<T, TDerived>) IAvaloniaReadOnlyList<TDerived>
ForEachItem<T>(Action<int, T>, Action<int, T>, Action, bool) IDisposable
Invokes an action for each item in a collection and subsequently each item added or removed from the collection.
ForEachItem<T>(Action<T>, Action<T>, Action, bool) IDisposable
Invokes an action for each item in a collection and subsequently each item added or removed from the collection.
TrackItemPropertyChanged<T>(Action<Tuple<object, PropertyChangedEventArgs>>) IDisposable
Listens for property changed events from all items in a collection.