I need to create a TextBox with only numbers but I couldn\'t do.
I have tried to put : InputScope = \"Numbers\" but this only work on Mobile.
Also I have tried on TextCha
Here is an O(1) solution without string matching
bool textCanceled = false;
private void TextBox_KeyDown(object sender, KeyRoutedEventArgs e)
{
if (!Char.IsDigit((char)e.Key))
textCanceled = true;
else
textCanceled = false;
}
private void TextBox_BeforeTextChanging(TextBox sender, TextBoxBeforeTextChangingEventArgs args)
{
args.Cancel = textCanceled;
}
might have to handle backspace char as a special case