Class AvaloniaListExtensions
- Namespace
- Avalonia.Collections
- Assembly
- Avalonia.Base.dll
Defines extension methods for working with AvaloniaList<T>s.
public static class AvaloniaListExtensions
- Inheritance
-
AvaloniaListExtensions
- Inherited Members
Methods
ForEachItem<T>(IAvaloniaReadOnlyList<T>, Action<int, T>, Action<int, T>, Action, bool)
Invokes an action for each item in a collection and subsequently each item added or removed from the collection.
public static IDisposable ForEachItem<T>(this IAvaloniaReadOnlyList<T> collection, Action<int, T> added, Action<int, T> removed, Action reset, bool weakSubscription = false)
Parameters
collection
IAvaloniaReadOnlyList<T>The collection.
added
Action<int, T>An action called initially for each item in the collection and subsequently for each item added to the collection. The parameters passed are the index in the collection and the item.
removed
Action<int, T>An action called for each item removed from the collection. The parameters passed are the index in the collection and the item.
reset
ActionAn action called when the collection is reset. This will be followed by calls to
added
for each item present in the collection after the reset.weakSubscription
boolIndicates if a weak subscription should be used to track changes to the collection.
Returns
- IDisposable
A disposable used to terminate the subscription.
Type Parameters
T
The type of the collection items.
ForEachItem<T>(IAvaloniaReadOnlyList<T>, Action<T>, Action<T>, Action, bool)
Invokes an action for each item in a collection and subsequently each item added or removed from the collection.
public static IDisposable ForEachItem<T>(this IAvaloniaReadOnlyList<T> collection, Action<T> added, Action<T> removed, Action reset, bool weakSubscription = false)
Parameters
collection
IAvaloniaReadOnlyList<T>The collection.
added
Action<T>An action called initially for each item in the collection and subsequently for each item added to the collection. The parameters passed are the index in the collection and the item.
removed
Action<T>An action called for each item removed from the collection. The parameters passed are the index in the collection and the item.
reset
ActionAn action called when the collection is reset.
weakSubscription
boolIndicates if a weak subscription should be used to track changes to the collection.
Returns
- IDisposable
A disposable used to terminate the subscription.
Type Parameters
T
The type of the collection items.
TrackItemPropertyChanged<T>(IAvaloniaReadOnlyList<T>, Action<Tuple<object?, PropertyChangedEventArgs>>)
Listens for property changed events from all items in a collection.
public static IDisposable TrackItemPropertyChanged<T>(this IAvaloniaReadOnlyList<T> collection, Action<Tuple<object?, PropertyChangedEventArgs>> callback)
Parameters
collection
IAvaloniaReadOnlyList<T>The collection.
callback
Action<Tuple<object, PropertyChangedEventArgs>>A callback to call for each property changed event.
Returns
- IDisposable
A disposable used to terminate the subscription.
Type Parameters
T
The type of the collection items.