/// <summary> /// Called when the target object is unloaded. /// </summary> /// <param name="target">The binding target object.</param> protected override void OnTargetUnloaded(FrameworkElement target) { target.DataContextChanged -= DatacontextTarget_DataContextChanged; // free up event handlers. delayTimer?.Stop(); if (bindingWatcher != null) { bindingWatcherDescriptor.RemoveValueChanged(bindingWatcher, BindingWatcher_SourcePropertyChanged); bindingWatcher.Dispose(); bindingWatcher = null; } }
/// <summary> /// Stops tracking path binding updates and release related resources. /// </summary> private void StopTrackingPathBindingUpdates() { if (boundPathBindingWatcher != null) { boundPathBindingWatcher.PropertyChanged -= BoundPathBindingWatcher_PropertyChanged; boundPathBindingWatcher.Dispose(); boundPathBindingWatcher = null; } }