Class ObservableDictionaryWrap<TKey, TValue>
Wraps a dictionary to provide property and collection changed notification events.
Inheritance
Implements
Inherited Members
Namespace: TheXDS.MCART.Types
Assembly: MCART.Mvvm.dll
Syntax
public class ObservableDictionaryWrap<TKey, TValue> : ObservableWrap<KeyValuePair<TKey, TValue>, IDictionary<TKey, TValue>>, INotifyPropertyChangeBase, IRefreshable, INotifyPropertyChanged, INotifyCollectionChanged, IDictionary<TKey, TValue>, ICollection<KeyValuePair<TKey, TValue>>, IEnumerable<KeyValuePair<TKey, TValue>>, IEnumerable where TKey : notnull
Type Parameters
| Name | Description |
|---|---|
| TKey | Type of the dictionary keys. |
| TValue | Type of elements contained in the dictionary. |
Constructors
| Edit this page View SourceObservableDictionaryWrap()
Initializes a new instance of the ObservableDictionaryWrap<TKey, TValue> class.
Declaration
public ObservableDictionaryWrap()
ObservableDictionaryWrap(IDictionary<TKey, TValue>)
Initializes a new instance of the ObservableDictionaryWrap<TKey, TValue> class.
Declaration
public ObservableDictionaryWrap(IDictionary<TKey, TValue> collection)
Parameters
| Type | Name | Description |
|---|---|---|
| IDictionary<TKey, TValue> | collection | Collection to use as the underlying dictionary. |
Properties
| Edit this page View Sourcethis[TKey]
Gets or sets the value at the specified key in the dictionary.
Declaration
public TValue this[TKey key] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | Key of the value to get or set. |
Property Value
| Type | Description |
|---|---|
| TValue | The value found at the specified key in the dictionary. |
Keys
Gets a collection containing all keys in the dictionary.
Declaration
public ICollection<TKey> Keys { get; }
Property Value
| Type | Description |
|---|---|
| ICollection<TKey> |
Values
Gets a collection containing all values in the dictionary.
Declaration
public ICollection<TValue> Values { get; }
Property Value
| Type | Description |
|---|---|
| ICollection<TValue> |
Methods
| Edit this page View SourceAdd(TKey, TValue)
Adds a value to this dictionary with the specified key.
Declaration
public void Add(TKey key, TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | Key to use. |
| TValue | value | Value to add to the dictionary. |
ContainsKey(TKey)
Determines whether the specified key exists in the dictionary.
Declaration
public bool ContainsKey(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | Key to look for in the dictionary. |
Returns
| Type | Description |
|---|---|
| bool |
Remove(TKey)
Removes the element with the specified key from the dictionary.
Declaration
public bool Remove(TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | Key to remove. |
Returns
| Type | Description |
|---|---|
| bool | true if the key was successfully removed from the dictionary; false if the key did not exist in the dictionary or if another error occurred while attempting the operation. |
TryGetValue(TKey, out TValue)
Attempts to get a value from the dictionary.
Declaration
public bool TryGetValue(TKey key, out TValue value)
Parameters
| Type | Name | Description |
|---|---|---|
| TKey | key | Key of the value to get. |
| TValue | value | Output parameter. Value obtained from the dictionary at the specified key. |
Returns
| Type | Description |
|---|---|
| bool | true if the value was obtained from the dictionary successfully; false if the key did not exist in the dictionary or if another error occurred while obtaining the value. |