/// <summary> /// IsEditableProperty property changed handler. /// </summary> /// <param name="d">UpDownBase that changed its IsEditable.</param> /// <param name="e">Event arguments.</param> private static void OnIsEditablePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { UpDownBase <T> source = d as UpDownBase <T>; bool oldValue = (bool)e.OldValue; bool newValue = (bool)e.NewValue; source.OnIsEditableChanged(oldValue, newValue); }
/// <summary> /// Property changed callback for SpinnerStyleProperty. /// </summary> /// <param name="d">UpDownBase whose SpinnerStyleProperty changed.</param> /// <param name="e">Event arguments.</param> private static void OnSpinnerStylePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { UpDownBase source = d as UpDownBase; Style oldValue = e.OldValue as Style; Style newValue = e.NewValue as Style; source.OnSpinnerStyleChanged(oldValue, newValue); }
/// <summary> /// ValueProperty property changed handler. /// </summary> /// <param name="d">UpDownBase whose Value changed.</param> /// <param name="e">Event arguments.</param> private static void OnValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { UpDownBase <T> source = (UpDownBase <T>)d; // Ignore the change if requested if (source._ignoreValueChange) { return; } T oldValue = (T)e.OldValue; T newValue = (T)e.NewValue; // simulate pre and post events // The Value has already been changed when this function is called. // So if user's chaning event handler check Value, it will be the changed value. // This is confusing, because we are simulating pre event on the platform that doesn't natively support it. RoutedPropertyChangingEventArgs <T> changingArgs = new RoutedPropertyChangingEventArgs <T>(e.Property, oldValue, newValue, true); source.OnValueChanging(changingArgs); // hack: work around the class hierarchy for value coercion in NumericUpDown if (changingArgs.InCoercion) { } else if (!changingArgs.Cancel) { newValue = (T)changingArgs.NewValue; ////if (!oldValue.Equals(newValue)) ////{ ////UpDownBaseAutomationPeer peer = nud.GetAutomationPeer() as UpDownBaseAutomationPeer; ////if (peer != null) ////{ //// peer.RaiseValuePropertyChangedEvent(oldValue, newValue); ////} RoutedPropertyChangedEventArgs <T> changedArgs = new RoutedPropertyChangedEventArgs <T>(oldValue, newValue); source.OnValueChanged(changedArgs); ////} } else { // revert back to old value if an event handler canceled the changing event. source._ignoreValueChange = true; source.Value = oldValue; source._ignoreValueChange = false; } }