c# - Setting the Default Value for Decimal Property in WPF Binding -



c# - Setting the Default Value for Decimal Property in WPF Binding -

i bound wpf form class's property decimal. textbox automatically higlighted in reddish if user come in invalid format (string instead of decimal). however, want create more secure validating before storing inserted info database.

the problem is, whenever user come in non decimal value, binding homecoming 0 instead of null or error. managed database without sec level validation.

what best way validate wpf binding decimal? right wont homecoming null not have means capture error.

here how bound textbox

<textbox x:name="stocktxtbx" grid.row="3" grid.column="1" style="{staticresource standardbox}" text="{binding stockonhand}"/>

also, can modify add together validation?

the problem is, whenever user come in non decimal value, binding homecoming 0 instead of null or error

you wrong in above statement. actually happens when user enters text has invalid type particular field this:

the invalid text causes reddish border (or other decoration depending on errortemplate value) appear around textbox the info bound property value remains @ last valid value entered

so, in case, lastly valid value may have been 0, why assumed invalid value homecoming 0. in fact, invalid value ignored, while lastly valid value remains.

however, improve issue, have several options. 1 way check value of validation.haserror attached property before save data. obviously, if observe errors present, popup message alert user, rather continuing save. can find out more method binding validation.haserror property in mvvm question.

another alternative restrict textual input of particular textbox not possible come in non numeric keys. won't go on details on how 1 time again here, instead preferring request @ answers numeric info entry in wpf question, here on stack overflow.

c# wpf mvvm

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -