這樣就可以做到只能輸入數字了。
DelayStartTimeTextBox.PreviewTextInput += StaticResourceModel.PreviewTextInput;
public static class StaticResourceModel
{
public static void PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = new System.Text.RegularExpressions.Regex("[^0-9]+").IsMatch(e.Text);
}
}
沒有留言:
張貼留言