Validation Event - WPF
I'm looking to develop a simple validation framework for WPF (the IDataErrorInfo method doesn't provide enough information for my needs) and I'm wondering if there is a way to get notified when a property will be validated? Note that I need to know when it will try to validate, not just when there is an error (so NotifyOnValidationError doesn't cut it)
Alternatively, my ultimate goal is to just pack more information than just a line of errors into my checks (how important is the error, links for more information, etc.) while still allowing the verification to manipulate the data object (IDataErrorInfo style). If someone can point me to a method to do this, I would love it too. :)
source to share
The problem you will run into is that WPF data binding and validation is bound to the IDataErrorInfo interface. The binding validation is validated against the binding's UpdateSourceTrigger property. Therefore, if your binding has "UpdateSourceTrigger = PropertyChanged", then every time the property changes, it will call the ["MyProperty"] element, in which you will return information about whether or not your property really belongs. If it is set to "LostFocus" then it checks when the control loses focus. The binding also requires "ValidatesOnDataErrors = True" for it to force validation of your associated entity.
I think your best bet is to create a class that implements IDataErrorInfo and then provide more details depending on the severity of the error.
source to share