<Page x:Class="TestDemo.PgBooks"
      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:TestDemo"
      mc:Ignorable="d" 
      d:DesignHeight="700" d:DesignWidth="800"
      Title="PgBooks"
      DataContext="{Binding RelativeSource={RelativeSource Mode=Self}}"
      Background="Bisque">

    <Page.Resources>
        <DataTemplate x:Key="ListView">
            <Border BorderBrush="Black" BorderThickness="1" Width="1000">
                <StackPanel Orientation="Horizontal">
                    <Image Source="{Binding cover}" Width="150" Height="150"></Image>
                    <StackPanel Orientation="Vertical">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Название: "></TextBlock>
                            <TextBlock Text="{Binding title_book}"></TextBlock>
                            <TextBlock Text=" | "></TextBlock>
                            <TextBlock Text="Жанр: "></TextBlock>
                            <TextBlock Text="{Binding genres.title_genre}"></TextBlock>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Автор: "></TextBlock>
                            <TextBlock Text="{Binding authors.name_author}"></TextBlock>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Цена: "></TextBlock>
                            <TextBlock Text="{Binding price, StringFormat=0.00}"  ></TextBlock>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Количество в магазине: "></TextBlock>
                            <TextBlock Text="{Binding CountInMagazine}"></TextBlock>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Количество на складе: "></TextBlock>
                            <TextBlock Text="{Binding CountInStock}"></TextBlock>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding description}" TextWrapping="WrapWithOverflow" Width="600" Height="100"></TextBlock>
                        </StackPanel>

                    </StackPanel>
                    <Button Uid="{Binding id_book}" Content="Добавить книгу в корзину" Height="50" x:Name="BtnAddCart" Click="BtnAddCart_Click" ></Button>
                </StackPanel>

            </Border>
        </DataTemplate>
    </Page.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="4*"/>
            <RowDefinition Height="31*"/>
        </Grid.RowDefinitions>
        <ListView ItemTemplate="{StaticResource ListView}" Background="Bisque" x:Name="MailList" Grid.Row="1"/>

        <Border Grid.Row="0" BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,6,20,4" Height="70" Width="250"  >
            <StackPanel Orientation="Vertical">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Количество выбранных книг:" FontSize="13" ></TextBlock>
                    <TextBlock Text="{Binding CountTakedBooks}"  FontSize="13"></TextBlock>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Стоимость покупки "  FontSize="13"></TextBlock>
                    <TextBlock Text="{Binding ItogPriceNonSale , StringFormat=0.00}" x:Name="TxtNonSale" TextDecorations="{Binding TextDecor}" FontSize="13" ></TextBlock>
                    <TextBlock Text=" "  FontSize="13"></TextBlock>
                    <TextBlock Text="{Binding PriceSale , StringFormat=0.00}"  FontSize="13"   x:Name="TxtYesSale" Visibility="Hidden"></TextBlock>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Размер скидки "  FontSize="13"></TextBlock>
                    <TextBlock Text="{Binding Sale}"   FontSize="13"></TextBlock>
                    <TextBlock Text="%"  FontSize="13"></TextBlock>
                </StackPanel>
                <Button x:Name="BtnGoCart" Click="BtnGoCart_Click" Content="Перейти в корзину"></Button>
            </StackPanel>

        </Border>
    </Grid>
</Page>
