<Window x:Class="TemplateForValidationError.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:TemplateForValidationError"
        mc:Ignorable="d"
      Title="TemplateForValidationError" Height="170" Width="360">
    <Window.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="Black" Offset="0"/>
            <GradientStop Color="#FFB9B3B3" Offset="1"/>
        </LinearGradientBrush>
    </Window.Background>

    <StackPanel>
        <TextBox Margin="20" Width="120" FontSize="14"  Grid.Column="1" Grid.Row="2">
            <Binding Path="Age" UpdateSourceTrigger="PropertyChanged">
                <Binding.ValidationRules>
                    <DataErrorValidationRule />
                </Binding.ValidationRules>
            </Binding>
            <TextBox.Style>
                <Style TargetType="TextBox">
                    <Setter Property="Validation.ErrorTemplate">
                        <Setter.Value>
                            <ControlTemplate>
                                <DockPanel>
                                    <TextBlock DockPanel.Dock="Left" Foreground="Red" FontSize="14" FontWeight="Bold"
                                               ToolTip="{Binding ElementName=adorner, 
                                               Path=AdornedElement.(Validation.Errors)[0].ErrorContent}" Text="***" />
                                    <Border BorderBrush="Yellow" BorderThickness="2">
                                        <AdornedElementPlaceholder Name="adorner" />
                                    </Border>
                                </DockPanel>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TextBox.Style>
        </TextBox>
    </StackPanel>
</Window>

