c# - how we put integer validation on text box in wpf -


I am creating a Wpf application I want to put the assumptions on the integer and the character text box.
How can I get it?

When you are outside of the price range and thus use validation rules, throw an exception Can

  & lt; Text box & gt; & Lt; TextBox.Text & gt; & Lt; Binding path = "number" & gt; & Lt; Binding.ValidationRules & gt; & Lt; Exceptional Rule / & gt; & Lt; /Binding.ValidationRules> & Lt; / Binding & gt; & Lt; /TextBox.Text> & Lt; / Text box & gt; More information can be found here:  

Update: In the back-code, you can do something like this:

  Personal Int _Number; Public string number {return {return _Number.ToString (); } Set {if (Int32.TryParse (value, out_Number)) {new application exception ("invalid integer number"); }}}  

Comments