コード例 #1
0
 private static void OnPaste(object sender, DataObjectPastingEventArgs e)
 {
     if (e.DataObject.GetDataPresent(typeof(string)))
     {
         if (NumericBehavior.IsTextAllowed((string)e.DataObject.GetData(typeof(string))))
         {
             return;
         }
         e.CancelCommand();
     }
     else
     {
         e.CancelCommand();
     }
 }
コード例 #2
0
 private static void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     e.Handled = !NumericBehavior.IsTextAllowed(e.Text);
 }