In my WPF application, I want to set NotifyOnValidationError to true (the framework defaults it to false) for all child controls/bindings if they have any ValidationRules attached to the binding. Indeed, it would be nice to specify other binding defaults too – e.g. ValidatesOnDataErrors should also always be true.
For example, in the following text box I don’t want to have to manually specify the NotifyOnValidationError property.
<TextBox>
<TextBox.Text>
<Binding Path="PostalCode"
ValidatesOnDataErrors="True"
NotifyOnValidationError="True">
<Binding.ValidationRules>
<rules:PostalCodeRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
Since
Bindingis just a markup extension you could create a custom Markup Extensions that extendsBindingand sets those properties to your desired defaults.