title: Validate textbox on key down event to accept only numbers in silverlight 4
body: <p>I need a validation to check whether key pressed down is numeric or not. I tried with different code but they cant help me out.In the textbox if the user press <code>Shift+numbers</code> it displays special characters like <code>!,@,#</code>...... I need to validate the <code>Shift + key down event</code>. </p>
  
  <p>//Code</p>
  
  <pre><code>    private void txtNumericTextbox_KeyDown(object sender, KeyEventArgs e)
              {
                  try
                  {
                      if (e.Key &lt; Key.D0 || e.Key &gt; Key.D9)
                      {
                          if (e.Key &lt; Key.NumPad0 || e.Key &gt; Key.NumPad9)
                          {
                              if (e.Key != Key.Back)
                              {
                                  txtNumericTextbox_.BorderBrush = new SolidColorBrush(Colors.Red);
                                  lblErrorMessage.Visibility = Visibility.Visible;
                                  lblErrorMessage.Text = "Please Enter Numbers Only";
                              }
                              else
                              {
                                  txtNumericTextbox_.BorderBrush = new SolidColorBrush(Colors.DarkGray);
                                  lblErrorMessage.Visibility = Visibility.Collapsed;
                                  lblErrorMessage.Text = "";
                              }
                          }
                      }
                   }
               }
  </code></pre>
  
  <p>How can I achieve that?</p>