ForEachItem<TKey, 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)
- C#
- VB
- F#
public static IDisposable ForEachItem<TKey, TValue>(
this IAvaloniaReadOnlyDictionary<TKey, TValue> collection,
Action<TKey, TValue> added,
Action<TKey, TValue> removed,
Action reset,
bool weakSubscription = false
)
<ExtensionAttribute>
Public Shared Function ForEachItem(Of TKey, TValue) (
collection As IAvaloniaReadOnlyDictionary(Of TKey, TValue),
added As Action(Of TKey, TValue),
removed As Action(Of TKey, TValue),
reset As Action,
Optional weakSubscription As Boolean = false
) As IDisposable
[<ExtensionAttribute>]
static member ForEachItem :
collection : IAvaloniaReadOnlyDictionary<'TKey, 'TValue> *
added : Action<'TKey, 'TValue> *
removed : Action<'TKey, 'TValue> *
reset : Action *
?weakSubscription : bool
(* Defaults:
let _weakSubscription = defaultArg weakSubscription false
*)
-> IDisposable
Parameters
- IAvaloniaReadOnlyDictionary(TKey, TValue)
- The collection.
- Action(TKey, 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.
- Action(TKey, TValue)
- 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. This will be followed by calls to added for each item present in the collection after the reset.
- Boolean (Optional)
- Indicates if a weak subscription should be used to track changes to the collection.
Type Parameters
- The key type of the collection items.
- 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 IAvaloniaReadOnlyDictionary(TKey, 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
Reference
AvaloniaDictionaryExtensions Class
Avalonia.Collections Namespace