Sdílet prostřednictvím


IObservableMap<K,V> Interface

Definition

Notifies listeners of dynamic changes to a map, such as when items are added or removed.

public interface class IObservableMap : IMap<K, V>
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.FoundationContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(1709124597, 48953, 16821, 174, 188, 90, 157, 134, 94, 71, 43)]
template <typename K, typename V>
struct IObservableMap : IMap<K, V>
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.FoundationContract), 65536)]
[Windows.Foundation.Metadata.Guid(1709124597, 48953, 16821, 174, 188, 90, 157, 134, 94, 71, 43)]
public interface IObservableMap<K,V> : IDictionary<K,V>
Public Interface IObservableMap(Of K, V)
Implements IDictionary(Of K, V)

Type Parameters

K
V
Derived
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.FoundationContract (introduced in v1.0)

Remarks

The IObservableMap<K,V> interface enables clients to register for notification events to IMap<K,V> collections. For example, you might use IObservableMap<K,V> when you need to keep two map structures synchronized. In this case, use the IObservableMap<K,V> interface to receive notification of changes, so that the associated data structure can be updated.

Observable collections are mainly useful for XAML data binding scenarios. For more info, see Data binding in depth.

Interface inheritance

IObservableMap<K,V> inherits IMap<K,V> and IIterable<T>. Types that implement IObservableMap<K,V> also implement the interface members of IMap<K,V> and IIterable<T>, with an IKeyValuePair<K,V> type constraint.

.NET usage

IObservableMap<K,V> isn't hidden for .NET usage. However, it's more common to use the .NET ObservableCollection<T> type (using a KeyValuePair as T) as a base class, or implement a Dictionary type or interface (generic or nongeneric) and INotifyCollectionChanged separately. If you do use IObservableMap<K,V> for .NET code, the base interfaces (and their members) project as System.Collections.Generic.IDictionary<TKey,TValue> and IEnumerable<T> (with KeyValuePair).

Events

MapChanged

Occurs when the map changes.

Applies to

See also