Skip to main content

ForEachItem<T>(IAvaloniaReadOnlyList<T>, Action<T>, Action<T>, Action, Boolean) Method

Invokes an action for each item in a collection and subsequently each item added or removed from the collection.

Definition

Namespace: Avalonia.Collections
Assembly: Avalonia.Base (in Avalonia.Base.dll)

public static IDisposable ForEachItem<T>(
this IAvaloniaReadOnlyList<T> collection,
Action<T> added,
Action<T> removed,
Action reset,
bool weakSubscription = false
)

Parameters

  IAvaloniaReadOnlyList(T)
The collection.
  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.
  Action(T)
An action called for each item removed from the collection. The parameters passed are the index in the collection and the item.
  Action
An action called when the collection is reset.
  Boolean  (Optional)
Indicates if a weak subscription should be used to track changes to the collection.

Type Parameters

The type of the collection items.

Return Value

IDisposable
A disposable used to terminate the subscription.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IAvaloniaReadOnlyList(T). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also

Reference

AvaloniaListExtensions Class
ForEachItem Overload
Avalonia.Collections Namespace