Class AvaloniaDictionary<TKey, TValue>
- Namespace
- Avalonia.Collections
- Assembly
- Avalonia.Base.dll
A notifying dictionary.
public class AvaloniaDictionary<TKey, TValue> : IAvaloniaDictionary<TKey, TValue>, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IAvaloniaReadOnlyDictionary<TKey, TValue>, IReadOnlyDictionary<TKey, TValue>, IReadOnlyCollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, INotifyCollectionChanged, INotifyPropertyChanged, IDictionary, ICollection, IEnumerable where TKey : notnull
Type Parameters
TKey
The type of the dictionary key.
TValue
The type of the dictionary value.
- Inheritance
-
AvaloniaDictionary<TKey, TValue>
- Implements
-
IAvaloniaDictionary<TKey, TValue>IDictionary<TKey, TValue>ICollection<KeyValuePair<TKey, TValue>>IAvaloniaReadOnlyDictionary<TKey, TValue>IReadOnlyDictionary<TKey, TValue>IReadOnlyCollection<KeyValuePair<TKey, TValue>>IEnumerable<KeyValuePair<TKey, TValue>>
- Inherited Members
- Extension Methods
Constructors
AvaloniaDictionary()
Initializes a new instance of the AvaloniaDictionary<TKey, TValue> class.
public AvaloniaDictionary()
AvaloniaDictionary(IDictionary<TKey, TValue>, IEqualityComparer<TKey>?)
Initializes a new instance of the AvaloniaDictionary<TKey, TValue> class using an IDictionary.
public AvaloniaDictionary(IDictionary<TKey, TValue> dictionary, IEqualityComparer<TKey>? comparer = null)
Parameters
dictionary
IDictionary<TKey, TValue>comparer
IEqualityComparer<TKey>
AvaloniaDictionary(int)
Initializes a new instance of the AvaloniaDictionary<TKey, TValue> class.
public AvaloniaDictionary(int capacity)
Parameters
capacity
int
Properties
Count
public int Count { get; }
Property Value
IsReadOnly
public bool IsReadOnly { get; }
Property Value
this[TKey]
Gets or sets the named resource.
public TValue this[TKey key] { get; set; }
Parameters
key
TKeyThe resource key.
Property Value
- TValue
The resource, or null if not found.
Keys
public ICollection<TKey> Keys { get; }
Property Value
- ICollection<TKey>
Values
public ICollection<TValue> Values { get; }
Property Value
- ICollection<TValue>
Methods
Add(TKey, TValue)
public void Add(TKey key, TValue value)
Parameters
key
TKeyvalue
TValue
Clear()
public void Clear()
ContainsKey(TKey)
public bool ContainsKey(TKey key)
Parameters
key
TKey
Returns
CopyTo(KeyValuePair<TKey, TValue>[], int)
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
Parameters
array
KeyValuePair<TKey, TValue>[]arrayIndex
int
GetEnumerator()
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<TKey, TValue>>
Remove(TKey)
public bool Remove(TKey key)
Parameters
key
TKey
Returns
TryGetValue(TKey, out TValue)
public bool TryGetValue(TKey key, out TValue value)
Parameters
key
TKeyvalue
TValue
Returns
Events
CollectionChanged
Occurs when the collection changes.
public event NotifyCollectionChangedEventHandler? CollectionChanged
Event Type
PropertyChanged
Raised when a property on the collection changes.
public event PropertyChangedEventHandler? PropertyChanged