<Page x:Class="UP_Session1_Belov.Pages.ProductListPage"
      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:UP_Session1_Belov.Pages" xmlns:models="clr-namespace:UP_Session1_Belov.Models" d:DataContext="{d:DesignInstance Type=models:ProductListModel}"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      Title="ProductListPage">

    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Background="White" VerticalAlignment="Center">
            <TextBlock Text="Фильтрация:" Margin="0 0 10 0"/>
            <StackPanel Orientation="Horizontal">
                <Label Content="Поиск:" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0 0 10 0"/>
                <TextBox x:Name="SearchFilter" Text="{Binding Search, UpdateSourceTrigger=PropertyChanged}" SelectedText="SearchFilter_TextChanged"  Height="23" Width="200" TextWrapping="Wrap" VerticalAlignment="Bottom" Margin="0 0 10 0"/>
                <TextBlock Text="По скидке:" Height="23" TextWrapping="Wrap" VerticalAlignment="Bottom" Margin="0 0 10 0"/>
                <ComboBox x:Name="filtres" VerticalAlignment="Center" Width="200" ItemsSource="{Binding Filters}" SelectedValue="{Binding IdFilterModel, Mode=TwoWay}" SelectedValuePath="Id" DisplayMemberPath="Name"  Margin="0 0 10 0"/>
                <TextBlock Text="По Цене:" Height="23" TextWrapping="Wrap" VerticalAlignment="Bottom" Margin="0 0 10 0"/>
                <ComboBox x:Name="DesAscSearch" VerticalAlignment="Center" Width="200" ItemsSource="{Binding SortCbName}" SelectedValue="{Binding IdSortModel, Mode=TwoWay}" SelectedValuePath="Id" DisplayMemberPath="Name" />
            </StackPanel>
        </StackPanel>
        
        <ListBox x:Name="productList" ItemsSource="{Binding Products}" Grid.Row="1">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                    <StackPanel Margin="0 0 10 0" Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">
                            <StackPanel Orientation="Horizontal">
                                <Image DataContext="{Binding Image}" Loaded="Image_Loaded" Width="100" Height="100" Source="/Resources/zaglushka.png" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0 0 15 0"/>

                                <StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0 0 15 0">
                                    <GroupBox Header="Название:">
                                        <TextBlock Text="{Binding Name}" Width="700" FontSize="16"/>
                                    </GroupBox>

                                    <GroupBox Header="Описание:">
                                        <TextBlock Text="{Binding Description}" Width="700" FontSize="16"/>
                                    </GroupBox>
                                    
                                    <GroupBox Header="Производитель:">
                                        <TextBlock Text="{Binding Manufacturer}" Width="700" FontSize="16"/>
                                    </GroupBox>
                                    
                                    <GroupBox Header="Стоимость:">
                                        <TextBlock x:Name="cost" Text="{Binding Cost}" Width="700" FontSize="16"/>
                                    </GroupBox>

                                    <GroupBox Header="Стоимость с учётом скидки:">
                                        <TextBlock x:Name="costWithDiscount" Text="{Binding CostWithDiscount}" Width="700" FontSize="16"/>
                                    </GroupBox>
                                </StackPanel>

                                    <StackPanel Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Center">
                                    <GroupBox x:Name="discount" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
                                        <TextBlock Text="{Binding Discount}" Loaded="TextBlock_Loaded" FontSize="48" VerticalAlignment="Center" HorizontalAlignment="Center" Width="150" Height="70"/>
                                    </GroupBox>
                                </StackPanel>
                            </StackPanel>
                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</Page>
