If your data items implement the
IDataErrorInfo interface found in the .NET Framework, the DataPresenter family of controls can display an error message(s) when the user enters invalid data in a cell. However, you must enable the data error information support by setting a FieldLayoutSettings object’s SupportDataErrorInfo property to a SupportDataErrorInfo enumeration value.
In addition to enabling support for data errors, the
SupportDataErrorInfo property determines whether the DataPresenter control displays the data error in a cell, record selector, or both.
The following screenshot shows a data error in the first record’s "ProductID" column:
The following table shows how the DataPresenter control accesses the methods/properties of the data items in order to obtain the error information which ultimately depends on the value of the
If you enable the data error support on the
FieldLayoutSettings object, any fields in the affected field layout will automatically report data errors. You can selectively disable this feature on a field by setting the SupportDataErrorInfo property exposed by a field object’s FieldSettings property to
You can also modify how the DataPresenter control reports data errors by setting a
FieldLayoutSettings object’s DataErrorDisplayMode property to a DataErrorDisplayMode enumeration value. Setting the
DataErrorDisplayMode property determines whether a data error is presented as an error icon, a highlight, or both.
If you enable support for either the
IDataErrorInfo interface or the
INotifyDataErrorInfo interface and you set the ValueConstraint property of an embedded xamEditor control, any value constraint errors will also cause the error icon and/or highlight to appear. Value constraints will force your end users to correct an error before they can move focus to a new cell. If you set a
FieldSettings object’s InvalidValueBehavior property to RevertValue, the cell’s value will automatically revert to its original value allowing your end users to move focus to a new cell. However, because the valued will always pass the value constraints, the DataPresenter control will never display an error icon and/or highlight. On the other hand, if you do not use value constraints, the DataPresenter control will display your data item’s error message in the appropriate cell and your end users can move focus to a new cell.
The following topics provide additional information related to this topic.