AvaloniaDictionaryExtensionsForEachItemTKey, TValue 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) Version: 11.3.999
public static IDisposable ForEachItem<TKey, TValue>(
	this IAvaloniaReadOnlyDictionary<TKey, TValue> collection,
	Action<TKey, TValue> added,
	Action<TKey, TValue> removed,
	Action reset,
	bool weakSubscription = false
)

Parameters

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

Type Parameters

TKey
The key type of the collection items.
TValue
The value 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 IAvaloniaReadOnlyDictionaryTKey, TValue. 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