Skip to main content

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.v24.1.dll

NuGet Package: DevExpress.Wpf.Core

Declaration

public DataTemplate ValidationErrorTemplate { get; set; }

Property Value

Type Description
DataTemplate

A DataTemplate that defines the visualization of the editor’s error messages.

Remarks

The code sample below demonstrates how to change the error template in all the TextEdit controls nested in a DataLayoutControl:

<Window
        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>
</Window>

The image below illustrates the result.

See Also