views:

178

answers:

1

Should IDataErrorInfo.Error check everyShould IDataErrorInfo.Error check every property? Or can I trust any clients to call IDataErrorInfo.Item on every property?

+1  A: 

IDataErrorInfo.Error is used to report the validation state for the whole object.

For example if your object have properties StartTime and EndTime you will probably want StartTime to be less than the EndTime and if this validation rule is broken it wont be appropriate to display a message neither for one nor the other property.

Error property is also appropriate to summarize the overall validation state of your object. So the answer is no - you shouldn't check every property. The error messages related to particular property are exposed by

string this[string columnName]

indexer.

EDIT: here a link that explains how the interface is supposed to be used.

Koynov
What you say sounds reasonable, but do you have anything to back it up? It seems that using reflection to get all the properties to check would be rather expensive.
Jonathan Allen
You can check out how Microsofts' controls (like DataGrid) reacts to the data implementing the interface. You can observe the calls which it makes. If you are still not convinced you can check http://msdn.microsoft.com/en-us/library/system.componentmodel.idataerrorinfo%28VS.95%29.aspx that link and the example how it is used.
Koynov