protected override void OnAttached() { base.OnAttached(); propertyWatcher.Attach(AssociatedObject); propertyWatcher.RegisterValueChangedHandler(ScrollViewer.HorizontalOffsetProperty, OnControlHorizontalOffsetChanged); propertyWatcher.RegisterValueChangedHandler(ScrollViewer.VerticalOffsetProperty, OnControlVerticalOffsetChanged); }
protected override void OnAttached() { base.OnAttached(); propertyWatcher.Attach(AssociatedObject); propertyWatcher.RegisterValueChangedHandler(FrameworkElement.ActualWidthProperty, OnActualWidthChanged); propertyWatcher.RegisterValueChangedHandler(FrameworkElement.ActualHeightProperty, OnActualHeightChanged); }
private static void SliderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var behavior = (ScaleFromSliderBehavior)d; var slider = (Slider)e.NewValue; slider.LayoutUpdated += behavior.SliderLayoutUpdated; watcher = new DependencyPropertyWatcher(slider); watcher.RegisterValueChangedHandler(RangeBase.MinimumProperty, behavior.SliderLayoutUpdated); watcher.RegisterValueChangedHandler(RangeBase.MaximumProperty, behavior.SliderLayoutUpdated); }
protected override void OnAttachedOverride() { propertyWatcher.Attach(AssociatedObject); if (SynchronizeWidth) { propertyWatcher.RegisterValueChangedHandler(FrameworkElement.ActualWidthProperty, WidthChanged); } if (SynchronizeHeight) { propertyWatcher.RegisterValueChangedHandler(FrameworkElement.ActualHeightProperty, HeightChanged); } RegisterElement(); }
protected override void OnAttached() { base.OnAttached(); propertyWatcher.Attach(AssociatedObject); propertyWatcher.RegisterValueChangedHandler(ItemsControl.ItemsSourceProperty, ItemsSourceChanged); UpdateCollectionView(); }
/// <inheritdoc/> public override void OnApplyTemplate() { base.OnApplyTemplate(); increaseButton = GetTemplateChild("PART_IncreaseButton") as RepeatButton; if (increaseButton == null) { throw new InvalidOperationException("A part named 'PART_IncreaseButton' must be present in the ControlTemplate, and must be of type 'RepeatButton'."); } decreaseButton = GetTemplateChild("PART_DecreaseButton") as RepeatButton; if (decreaseButton == null) { throw new InvalidOperationException("A part named 'PART_DecreaseButton' must be present in the ControlTemplate, and must be of type 'RepeatButton'."); } contentHost = GetTemplateChild("PART_ContentHost") as ScrollViewer; if (contentHost == null) { throw new InvalidOperationException("A part named 'PART_ContentHost' must be present in the ControlTemplate, and must be of type 'ScrollViewer'."); } var increasePressedWatcher = new DependencyPropertyWatcher(increaseButton); increasePressedWatcher.RegisterValueChangedHandler(ButtonBase.IsPressedProperty, RepeatButtonIsPressedChanged); var decreasePressedWatcher = new DependencyPropertyWatcher(decreaseButton); decreasePressedWatcher.RegisterValueChangedHandler(ButtonBase.IsPressedProperty, RepeatButtonIsPressedChanged); var textValue = FormatValue(Value); SetCurrentValue(TextProperty, textValue); contentHost.QueryCursor += HostQueryCursor; }
protected override void OnAttached() { var textProperty = AssociatedObject.GetDependencyProperties(true).FirstOrDefault(dp => dp.Name == nameof(AssociatedObject.Text)); if (textProperty == null) { throw new ArgumentException($"Unable to find public property '{nameof(AssociatedObject.Text)}' on object of type '{AssociatedObject.GetType().FullName}'."); } propertyWatcher.Attach(AssociatedObject); propertyWatcher.RegisterValueChangedHandler(textProperty, OnTextChanged); var adornerLayer = AdornerLayer.GetAdornerLayer(AssociatedObject); if (adornerLayer != null) { adorner = new HighlightBorderAdorner(AssociatedObject) { BackgroundBrush = null, BorderBrush = BorderBrush, BorderCornerRadius = BorderCornerRadius, BorderThickness = BorderThickness, State = HighlightAdornerState.Hidden, }; adornerLayer.Add(adorner); } }
public NotificationWindow(string caption, string message, ICommand command, object commandParameter) { InitializeComponent(); Caption = caption; Message = message; Command = command; CommandParameter = commandParameter; DataContext = this; var dependencyPropertyWatcher = new DependencyPropertyWatcher(this); dependencyPropertyWatcher.RegisterValueChangedHandler(ActualHeightProperty, (s, e) => SetPosition()); Loaded += NotificationWindowLoaded; }
protected override void OnAttached() { if (PropertyName == null) { throw new ArgumentException($"The PropertyName property must be set on behavior '{GetType().FullName}'."); } dependencyProperty = AssociatedObject.GetDependencyProperties(true).FirstOrDefault(dp => dp.Name == PropertyName); if (dependencyProperty == null) { throw new ArgumentException($"Unable to find property '{PropertyName}' on object of type '{AssociatedObject.GetType().FullName}'."); } propertyWatcher.Attach(AssociatedObject); // TODO: Register/Unregister handlers when the PropertyName changes propertyWatcher.RegisterValueChangedHandler(dependencyProperty, OnPropertyChanged); Binding.AddSourceUpdatedHandler(AssociatedObject, OnSourceUpdated); }