<UserControl x:Class="NorthwindClient.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dt="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:northwind="clr-namespace:NorthwindClient"
    Width="800" Height="600">
    <Grid x:Name="LayoutRoot" Background="AliceBlue">
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Margin="5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="50" />
            </Grid.ColumnDefinitions>
            <TextBox Grid.Column="0" x:Name="txtSearch" />
            <Button Grid.Column="1" x:Name="cmdSearch" Click="cmdSearch_Click" Content="Hledat" />
        </Grid>
        <dt:DataGrid x:Name="grdMain" Margin="5" Grid.Row="1" AutoGenerateColumns="False">
            <dt:DataGrid.Columns>
                <dt:DataGridTextColumn Header="Product Name" IsReadOnly="True" Binding="{Binding ProductName}" />
                <dt:DataGridTextColumn Header="Price" IsReadOnly="True" Binding="{Binding UnitPrice}">
                    <dt:DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="TextAlignment" Value="Right"/>
                        </Style>
                    </dt:DataGridTextColumn.ElementStyle>
                </dt:DataGridTextColumn>
                <dt:DataGridTextColumn Header="Category" IsReadOnly="True" Binding="{Binding Categories.CategoryName}" />
            </dt:DataGrid.Columns>
            <dt:DataGrid.RowDetailsTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Margin="5" Text="Supplier: " />
                            <TextBlock Margin="5" Text="{Binding Suppliers.CompanyName}"/>
                            <Button Margin="5" x:Name="cmdShowSupplier" Content="Show details" Tag="{Binding Suppliers}" Click="cmdShowSupplier_Click" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Margin="5" Text="Category: " />
                            <TextBlock Margin="5" Text="{Binding Categories.CategoryName}"/>                            
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </dt:DataGrid.RowDetailsTemplate>
        </dt:DataGrid>
        <northwind:SupplierView x:Name="frmSupplierView" Grid.RowSpan="2" Visibility="Collapsed" />
    </Grid>
</UserControl>
