<Page x:Class="Exxxam.ProductList"
      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:Exxxam"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      Title="ProductList">

    <Page.Resources>
        <BitmapImage x:Key="defaultImage" UriSource="/Resources/nolog.png"></BitmapImage>
    </Page.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <TextBlock Text="Список товаров" VerticalAlignment="Center" Margin="10" FontSize="18" FontWeight="SemiBold"></TextBlock>

        <Button Name="openShoppingCart" Content="Корзина" Width="100" Height="30" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed"></Button>

        <ListView Name="productList" Grid.Row="1" Background="Transparent" HorizontalContentAlignment="Stretch">
            <ListView.ContextMenu>
                <ContextMenu>
                    <MenuItem Name="addToShoppingCart" Header="Добавить в корзину" Click="addToShoppingCart_Click"></MenuItem>
                </ContextMenu>
            </ListView.ContextMenu>

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

            <ListView.ItemTemplate>
                <DataTemplate>
                    <DockPanel>
                        <Image Source="{Binding Photo_Prodiuct, TargetNullValue={StaticResource defaultImage}, FallbackValue={StaticResource defaultImage}}" Width="80" DockPanel.Dock="Left" Margin="5"></Image>

                        <StackPanel Margin="5">
                            <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" Text="{Binding Price_Product}" TextDecorations="Strikethrough" Visibility="Collapsed" Margin="0,0,5,0" Loaded="oldPrice_Loaded"></TextBlock>
                                <TextBlock Uid="{Binding Code_Product}" Name="mainPrice" Text="{Binding Price_Product}" Loaded="mainPrice_Loaded"></TextBlock>
                            </WrapPanel>
                        </StackPanel>

                        <TextBlock Uid="{Binding Code_Product}" Name="currentDiscount" Loaded="currentDiscount_Loaded" Visibility="Collapsed" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
                    </DockPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    
    
    </Grid> 
</Page>
