Validation errors may be triggered in several ways:
If a property setter in a data item throws an exception, an error message is displayed by the cell editor and the editor remains active until the error is corrected or until the changes are canceled.
If the data item implements the System.ComponentModel.IDataErrorInfo interface, then the item can raise column-level validation errors by implementing the default indexer and returning a column-specific error message (also displayed in the cell editor), or it can trigger item-level validation errors by setting the Error property to an error message. In this case, the error is not specific to any columns, and the error is displayed as an icon in the first cell in the row header.
If the data item implements the System.ComponentModel.INotifyDataErrorInfo interface, then the item can raise column-level or item-level validation errors as above, and it can raise those validation errors asynchronously. System.ComponentModel.INotifyDataErrorInfo is more complex and harder to implement than System.ComponentModel.IDataErrorInfo.
public class Product : INotifyPropertyChanged, IEditableObject, IDataErrorInfo { // ** method 1: throw an exception when setting the Price to negative values public double? Price { get { return (double?)GetValue("Price"); } set { if (value <= 0) { throw new Exception("Price must be greater than zero!"); } SetValue("Price", value); } } // ** method 2: return errors for specific columns string IDataErrorInfo.this[string columnName] { get { string msg = null; switch (columnName) { case "Cost": if (Cost <= 0) { msg = "Cost must be greater than zero!"; } break; } return msg; } } // ** method 3: return errors for the entire row // (validation depends on multiple columns) string IDataErrorInfo.Error { get { return Price < Cost ? "Price must be greater than Cost!" : null; } } }