<Window x:Class="Zadatak3.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:Zadatak3"
        mc:Ignorable="d"
        Title="MainWindow" Height="400" Width="500">
    <DockPanel>
        <Grid DockPanel.Dock="Bottom">
            <Grid.RowDefinitions>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <TreeView Grid.Column="0" Grid.Row="0" Name="trvKnjige" ItemsSource="{Binding Zanrovi}">
                <TreeView.Resources>
                    <HierarchicalDataTemplate DataType="{x:Type local:Zanr}" ItemsSource="{Binding Knjige}">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Naziv}"/>
                            <StackPanel.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="Dodaj" Command="{Binding Add}"></MenuItem>
                                </ContextMenu>
                            </StackPanel.ContextMenu>
                        </StackPanel>
                    </HierarchicalDataTemplate>
                    <DataTemplate DataType="{x:Type local:Knjiga}">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Naslov}" FontWeight="Bold"/>
                            <TextBlock Text=" ("/>
                            <TextBlock Text="{Binding ImeAutora}"/>
                            <TextBlock Text=" "/>
                            <TextBlock Text="{Binding PrezimeAutora}"/>
                            <TextBlock Text=")"/>
                        </StackPanel>
                    </DataTemplate>
                </TreeView.Resources>
            </TreeView>
            <ContentPresenter Grid.Column="1" Grid.Row="0" Content="{Binding ElementName=trvKnjige,Path=SelectedItem}">
                <ContentPresenter.Resources>
                    <DataTemplate DataType="{x:Type local:Knjiga}">
                        <Grid Margin="10 0 0 0">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <TextBlock Grid.Column="0" Grid.Row="0">Naslov:</TextBlock>
                            <TextBlock Grid.Column="0" Grid.Row="1">Ime autora:</TextBlock>
                            <TextBlock Grid.Column="0" Grid.Row="2">Prezime autora:</TextBlock>
                            <TextBlock Grid.Column="0" Grid.Row="3">Godina izdavanja:</TextBlock>
                            <TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Path=Naslov}"></TextBox>
                            <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Path=ImeAutora}"></TextBox>
                            <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Path=PrezimeAutora}"></TextBox>
                            <TextBox Grid.Column="1" Grid.Row="3" Text="{Binding Path=GodinaIzdanja}"></TextBox>
                        </Grid>
                    </DataTemplate>

                    <DataTemplate DataType="{x:Type local:Zanr}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Grid.Column="0" Grid.Row="0">Naziv:</TextBlock>
                            <TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Path=Naziv}"></TextBox>
                        </Grid>
                    </DataTemplate>
                </ContentPresenter.Resources>
            </ContentPresenter>
        </Grid>
    </DockPanel>
</Window>
