I want to make a TextBox as numeric, I tried this function:
<TextBox Name="txtProductId" PreviewTextInput="Number_Validation"/>
public static void Number_Validation(object sender,System.Windows.Input.TextCompositionEventArgs e)
{
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("[^0-9]+");
e.Handled = regex.IsMatch(e.Text);
}
But it accepts 'Space' and number. I don't need the space.