c# - WPF binding TextBox to integer property without throwing exception -


i binding textbox.text int property:

<textbox text="{binding lines, updatesourcetrigger=propertychanged}" />  private int _lines = 10; public int lines {     { return _lines; }     set { _lines = value; } } 

everything works expected simple code, there validation textbox. there exception system.formatexception thrown in output log. question is:
there elegant way rid of exception without reimplementing everything myself?
mean validators, convertors, etc. ton of code not call int32.tryparse instead of int32.parse. not exception thrown , handled wpf big problem, full log makes finding actual problems more difficult.

the question isn't clear, assume referring exception occurs if user enters invalid text (i.e. non-numeric, non-integer data).

afaik, wpf not include built-in control restricts user input. options are:


Comments

Popular posts from this blog

java - unable show chart in xls document using jasper reports -

javascript - How to change image src on success AJAX -

java.lang.RuntimeException: Could not generate dummy secret at sun.security.ssl.RSAClientKeyExchange.<init> -