private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { NumericTextBox numeric = d as NumericTextBox; if (numeric != null) { numeric.SetText(e.NewValue); } }
private static object CoerceValue(DependencyObject d, object baseValue) { NumericTextBox numeric = d as NumericTextBox; float min = numeric.Minimum; if (baseValue == null || min > (float)baseValue) { numeric.SetText(min); return(min); } float max = numeric.Maximum; if ((float)baseValue > max) { numeric.SetText(max); return(max); } return(baseValue); }