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

Gets or sets the style that will be used by the cells contained in the column when their content fails the validation process.

Syntax

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

Return Value

The style that will be used by the cells contained in the column when their content fails the validation process. By default, a null reference (Nothing in Visual Basic).

Example

All examples in this topic assume that the grid is bound to the Orders table of the Northwind database, unless stated otherwise.
The following example demonstrates how to provide a new style that will change the foreground color of a cell when its value fails the validation process. It uses the ShippingCostValidationRule custom validation rule defined in the previous example.
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_orders" 
                                    Source="{Binding Source={x:Static Application.Current}, 
                                                      Path=Orders}"/> 
   </Grid.Resources> 
   <xcdg:DataGridControl x:Name="OrdersGrid" 
                         ItemsSource="{Binding Source={StaticResource cvs_orders}}"> 
      <xcdg:DataGridControl.Resources> 
 
        <Style x:Key="cell_error" TargetType="{x:Type xcdg:DataCell}"> 
           <Setter Property="Foreground" Value="Red"/> 
        </Style> 
      </xcdg:DataGridControl.Resources>       
 
      <xcdg:DataGridControl.Columns> 
        <xcdg:Column FieldName="Freight" CellErrorStyle="{StaticResource cell_error}"> 
           <xcdg:Column.CellValidationRules> 
              <local:ShippingCostValidationRule/> 
           </xcdg:Column.CellValidationRules> 
        </xcdg:Column> 
      </xcdg:DataGridControl.Columns> 
   </xcdg:DataGridControl> 
</Grid>

Requirements

Supported Frameworks: Microsoft .NET Framework version 3.5

See Also