validation - WPF ValidationRules disables PropertyChanged -
i have following textbox have propertychanged in viewmodel. when insert binding.validationrules , insert wrong value, doesn't trigger propertychanged event , don't understand why. help?
<textbox name="riskcode" horizontalalignment="left" margin="101.923,8,0,81" textwrapping="wrap" width="56.077" maxlength="6" validation.errortemplate="{staticresource validationtemplate}" style="{staticresource textboxinerror}"> <textbox.text> <binding path="riskcode" updatesourcetrigger="propertychanged"> <binding.validationrules> <vm:riskcodevalidation/> </binding.validationrules> </binding> </textbox.text> </textbox>
use validationstep
.
http://msdn.microsoft.com/en-us/library/system.windows.controls.validationrule.validationstep.aspx
rawproposedvalue
- runs validationrule before conversion occurs.convertedproposedvalue
- runs validationrule after value converted.updatedvalue
- runs validationrule after source updated.committedvalue
- runs validationrule after value has been committed source.
by default, it's rawproposedvalue
, prevents binding source ever occurring - hence confusion. use different option instead:
<binding.validationrules> <vm:riskcodevalidation validationstep="updatedvalue" /> </binding.validationrules>
Comments
Post a Comment