title: C# WPF How to use only numeric value in a textbox
body: <p>I use a WPF application I would like to allow only numbers in a textbox. In a WindowsForm application I would know how I would have to make it.<br>
  Unfortunately, there is a KeyPress not in WPF and the "code" functioned also no longer.  </p>
  
  <p>How is it right and what is the event?</p>
  
  <hr>
  
  <p>Here you can see the old code that has worked in Windows Form:</p>
  
  <pre><code>private void tbKreisdurchmesser_KeyPress(object sender, KeyEventArgs e)
  {
      if (char.IsNumber(e.Key) || e.KeyChar==".")
      {
  
      }
      else
      {
          e.Handled = e.KeyChar != (char)Keys.Back;
      }
  }
  </code></pre>