<Window x:Class="R12_WalidacjaRegex.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:R12_WalidacjaRegex"
        mc:Ignorable="d"
        Title="Walidacja danych (Regex)" Height="180" Width="450">
    <Window.DataContext>
        <local:Osoba Nazwisko="Kowalski" Imiona ="Jan Andrzej" Pesel ="01234567890" KodPocztowy="40-000"/>
    </Window.DataContext>
    <Window.Resources>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="Margin" Value="5"/>
            <Setter Property="Width" Value="120"/>
            <Setter Property="Validation.ErrorTemplate">
                <Setter.Value>
                    <ControlTemplate>
                        <WrapPanel>
                            <AdornedElementPlaceholder/>
                            <TextBlock Text="{Binding CurrentItem.ErrorContent}" Foreground="Red" Margin="5,0"/>
                        </WrapPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
        </Grid.ColumnDefinitions>
        <Label Content="Nazwisko:" Grid.Row="0" Grid.Column="0"/>
        <TextBox Text="{Binding Nazwisko, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" Grid.Row="0" Grid.Column="1"/>
        <Label Content="Imiona:" Grid.Row="1" Grid.Column="0"/>
        <TextBox Text="{Binding Imiona, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" Grid.Row="1" Grid.Column="1"/>
        <Label Content="Pesel:" Grid.Row="2" Grid.Column="0"/>
        <TextBox Text="{Binding Pesel, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" Grid.Row="2" Grid.Column="1"/>
        <Label Content="Kod pocztowy:" Grid.Row="3" Grid.Column="0"/>
        <TextBox Text="{Binding KodPocztowy, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}" Grid.Row="3" Grid.Column="2"/>
    </Grid>
</Window>
