title: Silverlight numeric textbox?
body: <p>I tryed to create my own numeric textbox here is my code:</p>
  
  <pre><code>public class NumericTextBox : TextBox
  {
  
      public NumericTextBox()
          : base()
      {
          this.Text = "0";
      }
  
      private void HandleKeyEvent(KeyEventArgs e)
      {
          e.Handled = true;
          if ((Keyboard.Modifiers &amp; ModifierKeys.Alt) != 0)
          {
              return;
          }
          if (e.Key == Key.Back || e.Key == Key.Delete || e.Key == Key.Left || e.Key == Key.Right ||
              e.Key == Key.D0 || e.Key == Key.D1 || e.Key == Key.D2 || e.Key == Key.D3 || e.Key == Key.D4 || e.Key == Key.D5 || e.Key == Key.D6 ||
              e.Key == Key.D7 || e.Key == Key.D8 || e.Key == Key.D9 ||
              e.Key == Key.NumPad0 || e.Key == Key.NumPad1 || e.Key == Key.NumPad2 || e.Key == Key.NumPad3 || e.Key == Key.NumPad4 || e.Key == Key.NumPad5 || e.Key == Key.NumPad6 ||
              e.Key == Key.NumPad7 || e.Key == Key.NumPad8 || e.Key == Key.NumPad9)
          {
              e.Handled = false;
          }
          else if ((e.Key == Key.Subtract || (e.Key == Key.Unknown &amp;&amp; e.PlatformKeyCode == 189)) &amp;&amp; base.SelectionStart == 0 &amp;&amp; (base.Text.Length == 0 || base.Text[0] != '-'))
          {
              e.Handled = false;
          }
      }
  
      protected override void OnKeyDown(KeyEventArgs e)
      {
          HandleKeyEvent(e);
          base.OnKeyDown(e);
      }
  
      protected override void OnKeyUp(KeyEventArgs e)
      {
          HandleKeyEvent(e);
          base.OnKeyUp(e);
      }
  }
  </code></pre>
  
  <p>everything works like supposed but if you press alt and some numbers it creates the ascii symbol corresponding to the number.. is there any way to block an "alt + number combination?
  it seems that alt + key just gets entered without going threw OnKeyUp or OnKeyDown...</p>