title: Windows Phone 7 Textbox validation. I ONLY want numbers
body: <p>I cant' seem to get this to work.. On the WP7 the '%' is the same as the '5' as far as the e.Key is concerned.. How do I ONLY get the numbers...</p>
  
  <p>Or is there a open srouce WP7 textbox control that would work similiar to the AJAX control toolkit stuff so I can say.. Here is a TextBox.. ONLY ALLOW NUMBERS..? </p>
  
  <pre><code>if ((Keyboard.Modifiers &amp; ModifierKeys.Control) == ModifierKeys.Control)
          {
              e.Handled = false;
              return;
          }
  </code></pre>
  
  <p>then entire function is</p>
  
  <pre><code>  private void HandleKeyEvent(KeyEventArgs e)
      {
          e.Handled = true;
  
          if ((Keyboard.Modifiers &amp; ModifierKeys.Control) == ModifierKeys.Control)
          {
              e.Handled = false;
              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;
              //return;
          }
  
          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;
          }
  
          if (this.Text.Length &gt; 3)
          {
              e.Handled = true;
          }    
      }
  </code></pre>