0
votes

In MVVM we implement simple validations in the model class by implementing IDataErrorInfo my question is how can we validate business rules in MVVM like user already exist, etc.. currently I am thinking to implement business rules on save command, but the problem is how can I show an error to the user in validation error template the way IDateErrorInfo show error

1
updating a question its WPF Mvvm - Muhammad Faisal

1 Answers

4
votes

If you use WPF 4.5 you should take advantage of INotifyDataErrorInfo

You want an async validation here because you would need to reach out to the database.

here are some nice articles with background information:

WPF 4.5 – ASYNCHRONOUS VALIDATION https://anthymecaillard.wordpress.com/2012/03/26/wpf-4-5-validation-asynchrone/

WPF 4.5 – Part 1 : Asynchronous data validation http://www.jonathanantoine.com/2011/09/18/wpf-4-5-asynchronous-data-validation/

HTH