private static object ForceText(DependencyObject sender, object value) { if (!NumericTextBox.AreAllValidNumericChars((IEnumerable <char>)(string) value)) { throw new ArgumentException(); } else { return(value); } }
protected override void OnPreviewTextInput(TextCompositionEventArgs e) { e.Handled = !NumericTextBox.AreAllValidNumericChars((IEnumerable <char>)e.Text); base.OnPreviewTextInput(e); }