A reference to DataGridBindingInfo that provides information about a column's binding to its corresponding field in the underlying data source.
Remarks
Unless the ValidationRules collection is cleared, it will always contain an ExceptionValidationRule and DataErrorValidationRule. If the DataErrorValidationRule is excluded from the collection of validation rules, validation errors reported by IDataErrorInfo will be ignored.
Example
All examples in this topic assume that the grid is bound to a list of Composer objects, unless stated otherwise.
The following example demonstrates how to create a custom ValidationRule and apply it to a column's binding to provide binding-level validation.
using System;
using System.Windows.Controls;
using System.Globalization;
namespace Xceed.Wpf.Documentation
{
publicclass YearValidationRule : ValidationRule
{
publicoverride ValidationResult Validate( object value, CultureInfo cultureInfo )
{
int year = ( int )value;
if( year > DateTime.Now.Year )
returnnew ValidationResult( false, "Chosen year cannot be greater than this year." );
return ValidationResult.ValidResult;
}
}
}
Requirements
Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2