title: Validation and getting a value of a textbox
body: <p>Good Morning,</p>
  
  <p>I'm working on wpf application and i need to get the value of a textbox and check that it's number in the same time ! i checked the tutos and the forums on the net and i found that`</p>
  
  <pre><code>private void NumberValidationTextBox(object sender, TextCompositionEventArgs e)
      {
          Regex regex = new Regex("[^0-9]+");
          e.Handled = regex.IsMatch(e.Text);
      }
  </code></pre>
  
  <p>and here is the code in my XAML code </p>
  
  <pre><code>&lt;TextBox x:Name="sb" Width="50" Height="20" PreviewTextInput="NumberValidationTextBox" /&gt;
  </code></pre>
  
  <p>but i can't see how i can link between that method and the object ( textbox ) that i want to get the value from . Do i need to use a proprety on the XAML Code ? </p>