<UserControl x:Class="DatabaseEditor.Views.AuthorDetailView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:DatabaseEditor.Views"
             DataContext="{Binding AuthorDetailViewModel, Source={StaticResource ViewModelLocator}}"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Row="0" Text="Name: "/>
        <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding ItemDetail.Name}" />

        <TextBlock Grid.Row="1" Grid.Column="0" Text="Surname: "/>
        <TextBlock Grid.Row="1" Grid.Column="1"  Text="{Binding ItemDetail.Surname}" />

        <TextBlock Grid.Row="2" Grid.Column="0" Text="Books:" />
        <ItemsControl Grid.Row="2" Grid.Column="1"
                      HorizontalAlignment="Left" Height="Auto"
                      ItemsSource="{Binding ItemDetail.Books}">
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <TextBlock HorizontalAlignment="Left">
                        <Button Content="{Binding Name}"
                                Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type StackPanel}}, Path=DataContext.ShowRelatedItemCommand}"
                                CommandParameter="{Binding}"
                                Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" />
                    </TextBlock>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
        <StackPanel Grid.Row="3" Grid.Column="1"
                    VerticalAlignment="Bottom"
                    HorizontalAlignment="Right"
                    Orientation="Horizontal">
            <Button Content=" Edit " HorizontalAlignment="Right" VerticalAlignment="Bottom"
                    Command="{Binding EditCommand}" CommandParameter="{Binding ItemDetail}" />
            <Button Content="Delete" HorizontalAlignment="Right" VerticalAlignment="Bottom"
                    Command="{Binding DeleteCommand}" CommandParameter="{Binding ItemDetail}" />
        </StackPanel>
    </Grid>
</UserControl>