I am new to WPF and am using MVVM. I have found that using IDataErrorInfo is good for field based validation messages.
How do I take an error that has nothing to do with user input from the ViewModel and display it on the view?
I come from a MVC background where it is easy to pass and error back to the page with AJAX. I have tried binding a label for the time being to a general ErrorMessage propery in my ModelView, but this doesn’t feel right, as I am not sure where to reset the property.
I would rather not use a MessageBox.
Thank you very much for your help,
Richard Hughes
The best way I’ve found is to add a user control that represents a message box to the view that is being shown (or, if you are using a larger MVVM framework, add it to the shell.) Then, when I come across a general error where a message box would be used, I publish the event. The shell is subscribed to the show message event and when it receives it, centers the hidden control on the screen, displaying the message from the event.