protected override void OnDetaching() { base.OnDetaching(); this.AssociatedObject.Loaded -= this.AssociatedObjectLoaded; this.AssociatedObject.TextChanged -= this.AssociatedObjectTextChanged; this.notifier = null; }
private void AssociatedObjectLoaded(object sender, System.Windows.RoutedEventArgs e) { this.adorner = new TextBlockAdorner(this.AssociatedObject, this.Label, this.LabelStyle); this.UpdateAdorner(); //AddValueChanged for IsFocused in a weak manner this.notifier = new WeakPropertyChangeNotifier(this.AssociatedObject, UIElement.IsFocusedProperty); this.notifier.ValueChanged += new EventHandler(this.UpdateAdorner); }
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { WeakPropertyChangeNotifier notifier = (WeakPropertyChangeNotifier)d; notifier.ValueChanged?.Invoke(notifier, EventArgs.Empty); }