Updated: Input Validation – UI Exceptions & Model Validation Errors

I have completely rewritten the Input Validation – UI Exceptions & Model Validation Errors example code and post.

While in NY City with my great friend and MVVM Master Josh Smith we spoke a lot about the MVVM layers and when it is appropriate to put code in the View code behind file.

Since the Validation.ErrorEvent is a UI RoutedEvent it makes sense to handle this event in the View code behind and for this code to call directly to the ViewModel.

The resulting code is much simpler.  I had also added a Sequence Diagram to make understanding the data binding pipeline easier when a UI Control attempts to set a value on the Model it’s bound to and their is a type mismatch.

I hope you like and can learn more about WPF  and MVVM from this article and sample code.

Have a great day!

Just a grain of sand on the worlds beaches.

Leave a Reply

You must be logged in to post a comment.