Validating data datagrid

The method returns true or false depending on whether the validation succeeded or not and it also returns a collection of error messages as an out parameter.

For example, it would be useful if the Age property of the view model was constrained to only accept values between 10 and 100 and threw an exception if the value was outside of this range: interface.

Setting the property to this value means that the value of the source property only gets updated when you explicitly call the Binding Expression. You will typically never use this approach in an MVVM application though.

If you want to bind a view model property of a specific type to a dependency property in the view of a different type you may need to implement a custom converter class by implementing the interface and setting the Converter property of the binding to an instance of this.

This interface defines two properties that returns a string indicating what is wrong with the object and some property of the object respectively.

Below is how the view model would implement the interface – the same interface has been present in Silverlight since version 4 – which enables you to perform server-side validations asynchronously and then notify the view by raising an Errors Changed event once the validations are completed.

Leave a Reply