This documentation is archived and is not being maintained.

DataGrid.RowValidationErrorTemplate Property

Gets or sets the template that is used to visually indicate an error in row validation.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public ControlTemplate RowValidationErrorTemplate { get; set; }
    <ControlTemplate .../>

Property Value

Type: System.Windows.Controls.ControlTemplate
The template that is used to visually indicate an error in row validation. The registered default is null. For more information about what can influence the value, see DependencyProperty.

The DataGrid control enables you to perform validation at both the cell and row level. With cell-level validation, you validate individual properties of a bound data object when a user updates a value. With row-level validation, you validate entire data objects when a user commits changes to a row. You can provide customized visual feedback for row-level validation errors by specifying a ControlTemplate that defines the appearance of the error indicator. Set the RowValidationErrorTemplate property to null to use the default error indicator.

The following example replaces the default row validation feedback with a more visible indicator. When a user enters an invalid value, a red circle with a white exclamation mark appears in the row header. The associated error message is displayed in a ToolTip. This code example is part of a larger example provided for the How to: Implement Validation with the DataGrid Control topic.

    <Grid Margin="0,-2,0,-2"
      ToolTip="{Binding RelativeSource={RelativeSource
      FindAncestor, AncestorType={x:Type DataGridRow}},
      <Ellipse StrokeThickness="0" Fill="Red" 
        Width="{TemplateBinding FontSize}" 
        Height="{TemplateBinding FontSize}" />
      <TextBlock Text="!" FontSize="{TemplateBinding FontSize}" 
        FontWeight="Bold" Foreground="White" 
        HorizontalAlignment="Center"  />

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.