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

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -