DisplayMemberBindingInfo Property
See Also  Example
Xceed.Wpf.DataGrid Assembly > Xceed.Wpf.DataGrid Namespace > Column Class : DisplayMemberBindingInfo Property

Gets or sets the binding information between a column and its corresponding field in the underlying data source.

Syntax

Visual Basic (Declaration) 
Public Property DisplayMemberBindingInfo As DataGridBindingInfo
C# 
public DataGridBindingInfo DisplayMemberBindingInfo {get; set;}

Return Value

A reference to DataGridBindingInfo that provides information about a column's binding to its corresponding field in the underlying data source.

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.
XAMLCopy Code
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid" 
     xmlns:local="clr-namespace:Xceed.Wpf.Documentation"> 
  <Grid.Resources> 
     <xcdg:DataGridCollectionViewSource x:Key="cvs_composers" 
                                        Source="{Binding Source={x:Static Application.Current},  
                                                         Path=Composers}"/> 
  </Grid.Resources> 
  
  <xcdg:DataGridControl ItemsSource="{Binding Source={StaticResource cvs_composers}}" 
                        UpdateSourceTrigger="RowEndingEdit"> 
     <xcdg:DataGridControl.Columns>  
       <xcdg:Column FieldName="BirthYear"> 
          <xcdg:Column.DisplayMemberBindingInfo> 
             <xcdg:DataGridBindingInfo Path="BirthYear"> 
                <xcdg:DataGridBindingInfo.ValidationRules> 
                   <local:YearValidationRule /> 
                </xcdg:DataGridBindingInfo.ValidationRules> 
             </xcdg:DataGridBindingInfo> 
          </xcdg:Column.DisplayMemberBindingInfo> 
       </xcdg:Column> 
 
       <xcdg:Column FieldName="DeathYear"> 
          <xcdg:Column.DisplayMemberBindingInfo> 
             <xcdg:DataGridBindingInfo Path="DeathYear"> 
                <xcdg:DataGridBindingInfo.ValidationRules> 
                   <local:YearValidationRule /> 
                </xcdg:DataGridBindingInfo.ValidationRules> 
             </xcdg:DataGridBindingInfo> 
          </xcdg:Column.DisplayMemberBindingInfo> 
       </xcdg:Column>       
    </xcdg:DataGridControl.Columns> 
  </xcdg:DataGridControl> 
</Grid>
Implementation of the YearValidationRule validation rule.
Visual BasicCopy Code
Imports System
Imports System.Windows.Controls
Imports System.Globalization
Namespace Xceed.Wpf.Documentation

  Public Class YearValidationRule
               Inherits ValidationRule

    Public Overrides Function Validate( ByVal value As Object, _
                                        ByVal cultureInfo As CultureInfo ) As ValidationResult
      Dim year As Integer = CInt( value )
      If year > DateTime.Now.Year Then
        Return New ValidationResult( False, "Chosen year cannot be greater than this year." )
      End If
      Return ValidationResult.ValidResult
    End Function
  End Class
End Namespace
Implementation of the YearValidationRule validation rule.
C#Copy Code
using System;
using System.Windows.Controls;
using System.Globalization;
namespace Xceed.Wpf.Documentation
{

public class YearValidationRule : ValidationRule
{
  
public override ValidationResult Validate( object value, CultureInfo cultureInfo )
  {
    
int year = ( int )value;
    
if( year > DateTime.Now.Year )
      
return new ValidationResult( false, "Chosen year cannot be greater than this year." );
    
return ValidationResult.ValidResult;
  }
}
}

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.

Requirements

Supported Frameworks: Microsoft .NET Framework version 3.5

See Also