Class ObservableMemoryLayer<T>
Represents a memory-based layer that exposes its data as an observable collection and synchronizes feature changes with the underlying feature set.
Inherited Members
Namespace: Mapsui.Layers
Assembly: Mapsui.dll
Syntax
public class ObservableMemoryLayer<T> : MemoryLayer, ILayer, IAnimatable, INotifyPropertyChanged, IDisposable where T : class
Type Parameters
| Name | Description |
|---|---|
| T | The type of items contained in the observable collection. Must be a reference type. |
Remarks
This class enables two-way synchronization between an ObservableCollection of items and the set of features exposed by the layer. Changes to the collection are automatically reflected in the feature set, and vice versa. This is useful for scenarios where UI or other components need to observe and react to changes in the layer's data in real time.
Constructors
| Edit this page View SourceObservableMemoryLayer(Func<T, IFeature?>, string?)
Initializes a new instance of the ObservableMemoryLayer class with the specified feature selector and optional name.
Declaration
public ObservableMemoryLayer(Func<T, IFeature?> itemToFeature, string? name = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<T, IFeature> | itemToFeature | A function gets the IFeature instance related to the item of type T. This function is used to map items in the layer to their corresponding features. Cannot be null. |
| string | name | The optional name to assign to the layer. If null, a default name based on the type is used. |
Properties
| Edit this page View SourceObservableCollection
Gets or sets the underlying collection of items to observe for changes.
Declaration
public ObservableCollection<T>? ObservableCollection { get; set; }
Property Value
| Type | Description |
|---|---|
| ObservableCollection<T> |
Remarks
Assigning a new collection will update the internal state to reflect the contents of the provided collection and subscribe to its change notifications. If the collection is replaced, any previous event subscriptions are removed. Setting this property to null will clear the internal state and unsubscribe from change notifications.