<Window x:Class="SergechevExam.ShoppingCart"
        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:SergechevExam"
        mc:Ignorable="d"
        Title="НАЗВАНИЕ ОРГАНИЗАЦИИ" Height="450" Width="800">

    <Window.Resources>
        <BitmapImage x:Key="defaultImage" UriSource="/Resources/nolog.png"></BitmapImage>
    </Window.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="auto"/>
        </Grid.ColumnDefinitions>

        <TextBlock Text="Корзина" FontSize="18" FontWeight="Bold" VerticalAlignment="Center" Margin="5" Grid.Row="0"></TextBlock>

        <ListView Name="productList" Grid.Row="1" Background="Transparent" HorizontalContentAlignment="Stretch">
            <ListView.ContextMenu>
                <ContextMenu>
                    <MenuItem Name="addToCart" Header="Удалить из корзины" Click="addToCart_Click"></MenuItem>
                </ContextMenu>
            </ListView.ContextMenu>

            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel></StackPanel>
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>

            <ListView.ItemTemplate>
                <DataTemplate>
                    <DockPanel>
                        <Image Source="{Binding Photo_Product, TargetNullValue={StaticResource defaultImage}, FallbackValue={StaticResource defaultImage}}" DockPanel.Dock="Left" Width="150"></Image>
                        <StackPanel DockPanel.Dock="Top">
                            <TextBlock Text="{Binding Name_Product}"></TextBlock>
                            <TextBlock Text="{Binding Description_Product}"></TextBlock>

                            <WrapPanel>
                                <TextBlock Text="Производитель:" Margin="0,0,5,0"></TextBlock>
                                <TextBlock Text="{Binding Manufacturer.Name_Manufacturer}"></TextBlock>
                            </WrapPanel>

                            <WrapPanel>
                                <TextBlock Text="Цена:" Margin="0,0,5,0"></TextBlock>
                                <TextBlock Uid="{Binding Code_Product}" Name="oldPrice" Margin="0,0,5,0" Text="{Binding Price_Product}" Visibility="Collapsed" TextDecorations="Strikethrough" Loaded="oldPrice_Loaded"></TextBlock>
                                <TextBlock Uid="{Binding Code_Product}" Name="mainPrice" Loaded="mainPrice_Loaded"></TextBlock>
                            </WrapPanel>

                            <WrapPanel>
                                <TextBlock Text="Количество: " Margin="0,0,5,0"></TextBlock>
                                <TextBox Uid="{Binding Code_Product}" Text="{Binding Count}" Width="150"></TextBox>
                            </WrapPanel>
                        </StackPanel>

                        <TextBlock Uid="{Binding Code_Product}" Name="discount" Visibility="Collapsed" Text="{Binding Discount_Product}" Loaded="discount_Loaded" HorizontalAlignment="Right" DockPanel.Dock="Top" VerticalAlignment="Center"></TextBlock>
                    </DockPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</Window>
