<Window x:Class="UserDefinedValidationRule_Sample.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:UserDefinedValidationRule_Sample"
        mc:Ignorable="d"
        Title="UserDefinedValidationRule" Height="150" Width="280">
    <Window.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="Black" Offset="0"/>
            <GradientStop Color="White" Offset="1"/>
        </LinearGradientBrush>
    </Window.Background>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Label Foreground="White" Content="{Binding ElementName=txtAlter, Path=(Validation.Errors)[0].ErrorContent}" />
        <TextBox Grid.Row="1" Margin="8" Name="txtAlter">
            <Binding Path="Age" UpdateSourceTrigger="PropertyChanged">
                <Binding.ValidationRules>
                    <local:AgeValidationRule />
                </Binding.ValidationRules>
            </Binding>
        </TextBox>
    </Grid>
</Window>
