/// <summary> Initializes a new instance of the <see cref="MapCanvas"/> class. Stores the parent map and adds /// listeners to the map viewport changed events. </summary> /// <param name="mapView"> The instance of the parent map. </param> protected MapCanvas(MapView mapView) { MapView = mapView; ViewportBeginChangedWeakEventManager.AddListener(mapView, this); ViewportEndChangedWeakEventManager.AddListener(mapView, this); ViewportWhileChangedWeakEventManager.AddListener(mapView, this); }
/// <summary> Disposes the map canvas. During disposal the children of the canvas are removed and the viewport /// changed events are disconnected. </summary> public virtual void Dispose() { (Parent as Canvas)?.Children.Remove(this); ViewportBeginChangedWeakEventManager.RemoveListener(MapView, this); ViewportWhileChangedWeakEventManager.RemoveListener(MapView, this); ViewportEndChangedWeakEventManager.RemoveListener(MapView, this); }