His code is buggy when I write this. get ter will throw a StackOverflowException if thrown.
When the binding is configured to perform validation
<TextBox Text="{Binding Hurr, ValidatesOnDataErrors=true}" />
the binding system will be, if the data source object implements IDataErrorInfo , use two methods of this interface to perform validation.
The interface indexer takes a string, which is the name of the property to check, and returns a string, which is a check error, if any, of the current value of the property.
An example of this might be ...
var pet = new Pet(); var error = pet["Name"]; //"Your pet has no name!" pet.Name = "Fido"; error = pet["Name"]; //"Come on, how unoriginal is that?"
His concrete code example handles the validation in the type getter / setter odd. This is not a universal example of how to implement IDataErrorInfo , but rather, derive your personal touches from your personal code. Most people have their own way of implementing it, but 9-10 times it will be a switch with property names that are individual case s.
source share