Export (0) Print
Expand All
Expand Minimize

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)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

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

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.

<DataGrid.RowValidationErrorTemplate>
  <ControlTemplate>
    <Grid Margin="0,-2,0,-2"
      ToolTip="{Binding RelativeSource={RelativeSource
      FindAncestor, AncestorType={x:Type DataGridRow}},
      Path=(Validation.Errors)[0].ErrorContent}">
      <Ellipse StrokeThickness="0" Fill="Red" 
        Width="{TemplateBinding FontSize}" 
        Height="{TemplateBinding FontSize}" />
      <TextBlock Text="!" FontSize="{TemplateBinding FontSize}" 
        FontWeight="Bold" Foreground="White" 
        HorizontalAlignment="Center"  />
    </Grid>
  </ControlTemplate>
</DataGrid.RowValidationErrorTemplate>

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft