His code is buggy as I write this. The get
ter would throw a StackOverflowException if called.
When a Binding is configured to perform validation
<TextBox Text="{Binding Hurr, ValidatesOnDataErrors=true}" />
the binding system will, if the data source object implements IDataErrorInfo, use the two methods of that interface to perform validation.
The indexer of the interface takes a string which is the name of the property to validate, and returns a string which is the validation 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 particular code sample is handling validation in the getter/setter kind of odd. Its not a universal example of how implementing IDataErrorInfo
should be, but more likely a snip out of his own personal code with his own personal touches. Most people have their own way of implementing it, but 9/10 times its going to be a switch
statement with the property names all being individual case
s.