<Page x:Class="Sessioa.Pages.ProductsPage"
      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:Sessioa.Pages"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      Title="ProductsPage">
    <Page.Resources>
        <BitmapImage x:Key="defaultImage" UriSource="/Resources/picture.png"/>
    </Page.Resources>
    <Grid>
        <ListBox Name="LB_Product" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border BorderBrush="#498C51" BorderThickness="3" CornerRadius="5" Uid="{Binding ProductArticleNumber}" Loaded="Border_Loaded">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="0.3*"/>
                                <ColumnDefinition Width="2*"/>
                                <ColumnDefinition Width="0.5*"/>
                            </Grid.ColumnDefinitions>
                            <Image Source="{Binding ProductPhoto, TargetNullValue={StaticResource defaultImage}}" Margin="5" MaxWidth="80"/>
                            <StackPanel Grid.Column="1">
                                <TextBlock Text="{Binding ProductName}" Style="{StaticResource TextBlockBold}"/>
                                <TextBlock Text="{Binding ProductDescription}" Style="{StaticResource TextBlock}"/>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="Производитель:" Style="{StaticResource TextBlock}" Margin="0,0,5,0"/>
                                    <TextBlock Text="{Binding Manufacturer.ProductManufacturer}" Style="{StaticResource TextBlock}"/>
                                </StackPanel>
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="Цена: " Style="{StaticResource TextBlock}" Margin="0,0,5,0"/>
                                    <TextBlock Name="countPr" Text="{Binding ProductCost, StringFormat={}{0:C}}" Style="{StaticResource TextBlock}" Uid="{Binding ProductArticleNumber}" Loaded="countPr_Loaded"/>
                                    <TextBlock Name="countDPr" Style="{StaticResource TextBlock}" Uid="{Binding ProductArticleNumber}" Visibility="Collapsed" Loaded="countPr_Loaded_1" Margin="5,0,0,0"/>
                                </StackPanel>
                            </StackPanel>
                            <TextBlock Name="Discount" Loaded="Discount_Loaded" Uid="{Binding ProductArticleNumber}" Style="{StaticResource TextBlock}" Grid.Column="2" VerticalAlignment="Center"/>
                        </Grid>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</Page>
