This project is read-only.

UpdateControls and IDataErrorInfo

Feb 3, 2010 at 7:41 PM

Hello Michael,
First, thank very much for all the work that you have done with UpdateControls and that you are giving it for free.
It is an awesome library, much better then Cinch or MEF or other, although they try to solve different set of problems.
The documentation is great, examples are very clean and easy to follow.
Now question. What would be your recommendation on how to use UpdateControls with IDataErrorInfo? I could not find any examples on this topic. May be you have a different approach. 

Thank you,

Feb 3, 2010 at 9:51 PM

Can anyone contribute in here. When using UpdateControls how would you perform data validation (run validation rules) and report errors using IDataErrorInfo. Since we are not firing INotifyPropertyChanged how would you run your validation logic? What is the recommende way?

Feb 4, 2010 at 6:28 PM

The easiest way to validate is to throw an exception from the setter, either in your View Model or in your Data Model. Set ValidatesOnExceptions to True in your Binding, such as: Text="{Binding Number, ValidatesOnExceptions=True}".

UpdateControls currently does not support the IDataErrorInfo interface. If you do implement it on your view model, ForView.Wrap will hide it. I will correct this problem shortly.

Feb 4, 2010 at 7:15 PM

Aha. I see now. Thank you for your suggestion, it helps.

I know it is probably not in your priority but do you know by any chance when you are going to change ForView.Wrap to allow IDataErroInfo, or may be come up with some other genious way to report data errors?

Thanks a lot, I like your library and T4 for Linq to SQL is great as well.

I was also thinking of changing T4 so that setter methods will run something like ValidateAll(List<Action<T>>) which would accept some sort of an array of validation rule delegates from corresponding partial classes. I am just not sure how to report multiple errors when IDataErrorInfo is blocked. I need to look into ValidatesOnExceptions.



Feb 4, 2010 at 7:29 PM

I just checked in the changes for IDataErrorInfo support. You will need to set ValidatesOnDataErrors=True in your binding and implement IDataErrorInfo on your view model. ForView.Wrap() forwards all IDataErrorInfo calls.

Thanks for the request.


Feb 4, 2010 at 7:31 PM

Oh wow, that was lightning fast! Thank you!