Force validation on bound controls in WPF

In 3.5SP1 / 3.0SP2, they also added a new property to the ValidationRule base, namely, ValidatesOnTargetUpdated=”True”. This will call the validation as soon as the source object is bound, rather than only when the target control is updated. That may not be exactly what you want, but it’s not bad to see initially all the stuff you need to fix.

Works something like this:

    <Binding Path="Amount" StringFormat="C">
                ErrorMessage="The pledge amount is required." 
                ValidatesOnTargetUpdated="True"  />
                ErrorMessage="The pledge amount must be numeric." 
                ValidatesOnTargetUpdated="True"  />

Leave a Comment