/// <summary> /// "Value" dependency property callback /// </summary> /// <param name="target">target</param> /// <param name="e">arguments</param> private static void OnValuePropertyChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) { DoubleBox targetControl = target as DoubleBox; double.TryParse(targetControl.TextBoxValue, out double oldValue); double newValue = (double)e.NewValue; if (newValue != oldValue)// avoid infinite recursion { targetControl.SetTextBoxValue(newValue); } }
private static void OnIsReadOnlyPropertyChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) { DoubleBox targetControl = target as DoubleBox; bool newValue = (bool)e.NewValue; targetControl.numericBox.IsReadOnly = newValue; if (newValue) { targetControl.btnUp.Visibility = Visibility.Collapsed; targetControl.btnDown.Visibility = Visibility.Collapsed; } else { targetControl.btnUp.Visibility = Visibility.Visible; targetControl.btnDown.Visibility = Visibility.Visible; } }