I\'m developing a custom text box for currency editing.
I\'ve seen some ready to use ones, but they\'re complicated and/or not really usable, forcing you to bad practi
take look on this article i think it will help you. http://www.codeproject.com/Articles/15239/Validation-in-Windows-Presentation-Foundation
or you can put this
private static bool IsTextAllowed(string text)
{
Regex regex = new Regex("[^0-9.-]+"); //regex that matches disallowed text
return !regex.IsMatch(text);
}
and in PreviewTextInput event put this
e.Handled = !IsTextAllowed(e.Text);