<Window x:Class="MVVM_Sample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:MVVM_Sample.ViewModel"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        Name="mainWindow"
        Title="MVVM_Sample9" Height="400" Width="550">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Resources\NavigationButtons.xaml" />
                <ResourceDictionary Source="Resources\AnzeigeTextboxen.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <local:MainViewModel x:Key="vm" />
        </ResourceDictionary>
    </Window.Resources>

    <Window.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="#FF7C7985" Offset="0"/>
            <GradientStop Color="White" Offset="1"/>
        </LinearGradientBrush>
    </Window.Background>

    <Grid DataContext="{StaticResource vm}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>


        <DockPanel Grid.Row="0" Height="24" Background="LightGray" LastChildFill="False">
            <Button Command="{Binding FirstCommand}" Template="{StaticResource navFirst}" Margin="3" />
            <Button Command="{Binding PreviousCommand}" Template="{StaticResource navPrevious}" Margin="3" />
            <TextBox Width="150" Text="{Binding ActualPosition, Mode=OneWay}"/>
            <Button Command="{Binding NextCommand}" Template="{StaticResource navNext}" Margin="3" />
            <Button Command="{Binding LastCommand}" Template="{StaticResource navLast}" Margin="3" />
            <ComboBox DockPanel.Dock="Right" Width="140" ItemsSource="{Binding SortCriteria, Mode=OneWay}" SelectedValue="{Binding SortByProperty}" />
            <Label Margin="0 0 10 0" DockPanel.Dock="Right" FontSize="12" Padding="0" VerticalAlignment="Center">Sortierung:</Label>
        </DockPanel>


        <ListView ItemsSource="{Binding PersonsView, Mode=OneWay}" Grid.Row="1" SelectionMode="Single" Name="listView" Margin="3 5 3 10">
            <ListView.View>
                <GridView>
                    <GridViewColumn DisplayMemberBinding="{Binding Changed}" Header="" Width="20" />
                    <GridViewColumn DisplayMemberBinding="{Binding LastName.Value, TargetNullValue=[keine Angabe]}" Header="LastName" Width="100" />
                    <GridViewColumn DisplayMemberBinding="{Binding FirstName.Value, TargetNullValue=[keine Angabe]}" Header="FirstName" Width="100" />
                    <GridViewColumn DisplayMemberBinding="{Binding BirthDate.Value, TargetNullValue=[keine Angabe]}" Header="BirthDate" Width="100" />
                    <GridViewColumn DisplayMemberBinding="{Binding City.Value, TargetNullValue=[keine Angabe]}" Header="City" Width="100" />
                </GridView>
            </ListView.View>
        </ListView>

        <Grid Grid.Row="2" DataContext="{Binding SelectedItem, ElementName=listView}" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Label Grid.Row="0" Grid.Column="0">FirstName:</Label>
                <Label Grid.Row="1" Grid.Column="0">LastName:</Label>
                <Label Grid.Row="2" Grid.Column="0">City:</Label>
                <Label Grid.Row="3" Grid.Column="0">BirthDate:</Label>
                <TextBox local:FocusControl.Focus="{Binding Source={StaticResource vm}, Path=SetFocus, Mode=TwoWay}" DataContext="{Binding FirstName}" Text="{Binding Value}" Name="txtFirstName" Grid.Row="0" Grid.Column="1" />
                <TextBox DataContext="{Binding LastName}" Text="{Binding Value}" Name="txtLastName" Grid.Row="1" Grid.Column="1" />
                <TextBox DataContext="{Binding City}" Text="{Binding Value}" Name="txtCity" Grid.Row="2" Grid.Column="1" />
                <TextBox  DataContext="{Binding BirthDate}" Text="{Binding Value, TargetNullValue=[keine Angabe]}" Name="txtBirthDate" Grid.Row="3" Grid.Column="1">
                    <TextBox.Style>
                        <Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding HasError}" Value="true">
                                    <Setter Property="BorderThickness" Value="2" />
                                    <Setter Property="BorderBrush" Value="Red" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBox.Style>
                </TextBox>
            </Grid>
            <Grid Name="gridInfo" Grid.Row="0" Grid.Column="2" Grid.RowSpan="4" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Label Grid.Row="0">Details:</Label>
                <TextBox DataContext="{StaticResource vm}" Text="{Binding PersonDetails, UpdateSourceTrigger=PropertyChanged}" Name="txtDetailInformation" Grid.Row="1" TextWrapping="Wrap">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="MouseEnter">
                            <i:InvokeCommandAction Command="{Binding MouseEnterCommand}" />
                        </i:EventTrigger>
                        <i:EventTrigger EventName="MouseLeave">
                            <i:InvokeCommandAction Command="{Binding MouseLeaveCommand}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
            </Grid>
        </Grid>

        <StackPanel Grid.Row="3" Orientation="Horizontal">
            <Button Width="80" Margin="5 12 0 5"
                    Command="ApplicationCommands.New" Content="{Binding Text, Source={x:Static ApplicationCommands.New}}" />
            <Button Width="80" Margin="8 12 0 5"
                    Command="ApplicationCommands.Save" Content="{Binding Text,Source={x:Static ApplicationCommands.Save}}"/>
            <Button Width="80" Margin="8 12 0 5"
                    Command="ApplicationCommands.Delete" Content="{Binding Text, Source={x:Static ApplicationCommands.Delete}}"/>
            <Button Width="80" Margin="8 12 0 5" 
                    Command="ApplicationCommands.Undo" Content="{Binding Text, Source={x:Static ApplicationCommands.Undo}}" />
        </StackPanel>
    </Grid>
</Window>

