BaseEdit.ValidationErrorTemplate Property
Gets or sets the template used to display an editor’s validation error messages. This is a dependency property.
Namespace: DevExpress.Xpf.Editors
Assembly: DevExpress.Xpf.Core.v26.1.dll
Declaration
Property Value
| Type | Description |
|---|---|
| DataTemplate | A DataTemplate that defines the visualization of the editor’s error messages. |
Remarks
The DataContext of elements inside the template is a BaseValidationError object. Bind to BaseValidationError.ErrorContent to display the error message, or to BaseValidationError.ErrorType to change the appearance based on error severity.
The following code sample changes the error template for all TextEdit controls nested in a DataLayoutControl:
<dx:ThemedWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:InputValidationExample"
xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
x:Class="InputValidationExample.MainWindow"
Title="MainWindow" Height="450" Width="650">
<Grid>
<dxlc:DataLayoutControl
CurrentItem="{Binding}"
AutoGenerateItems="False"
HorizontalAlignment="Left"
Width="250">
<dxlc:DataLayoutControl.Resources>
<DataTemplate x:Key="errorTemplate" >
<Image Source="{dx:DXImage 'Images/XAF/State_Validation_Warning.png'}"/>
</DataTemplate>
<Style TargetType="dxe:TextEdit">
<Setter
Property="ValidationErrorTemplate"
Value="{StaticResource errorTemplate}"/>
</Style>
</dxlc:DataLayoutControl.Resources>
<dxlc:DataLayoutItem Label="User ID">
<dxe:TextEdit EditValue="{Binding UserID, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"/>
</dxlc:DataLayoutItem>
<dxlc:DataLayoutItem Label="Name">
<dxe:TextEdit EditValue="{Binding Name, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" />
</dxlc:DataLayoutItem>
</dxlc:DataLayoutControl>
</Grid>
</dx:ThemedWindow>
The image below illustrates the result:

See Also