
Hi Brad,
Unfortunately there isn't a built-in way to prevent certain typing of text since numbers can be specified in multiple ways, basically any number-related text that can be parsed from a string in the current culture. For doubles, that even includes E-notation, etc.
The edit box has a TextBox in its template that is where you type into. We watch for changes in that and the convert its Text to a double value in the virtual TryConvertFromString method.
You could try something like this in a TryConvertFromString override:
protected internal override bool TryConvertFromString(string textToConvert, bool canCoerce, out Double? value) {
var success = base.TryConvertFromString(textToConvert, canCoerce, out value);
if ((success) && (value == 1.9519) && (ActiproSoftware.Windows.Media.VisualTreeHelperExtended.GetFirstDescendant(this, typeof(TextBox)) is TextBox textBox)) {
textBox.Text = "1.951";
textBox.SelectionStart = textBox.Text.Length;
return false;
}
return success;
}
Obviously that is a specific test for your scenario and you'd want to rework it to be more general.