<Window x:Class="WpfApp1.MainWindow"
        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:WpfApp1"
        mc:Ignorable="d"
        Title="Иванов Валера И-211" Height="450" Width="908">
    <Window.Resources>
        <Style 
        x:Key="StackStyle" 
        TargetType="ListBox">
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <StackPanel 
                        Orientation="Vertical"/>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style 
        x:Key="WrapStyle" 
        TargetType="ListBox">
            <Setter Property="ItemsPanel">
                <Setter.Value>
                    <ItemsPanelTemplate>
                        <WrapPanel 
                        HorizontalAlignment="Center"
                        ItemWidth="200"/>
                    </ItemsPanelTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style 
            TargetType="Button">
            <Setter 
                Property="FontFamily" 
                Value="Verdana" />
            <Setter 
                Property="Background" 
                Value="Black" />
            <Setter 
                Property="Foreground" 
                Value="White" />
            <Setter 
                Property="Margin" 
                Value="10" />
        </Style>
    </Window.Resources>


    <Grid ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition />
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>

        <!-- лого -->
        <Image 
        Source="./bin/Debug/net8.0-windows/img/net.jpg" 
        Grid.RowSpan="2" HorizontalAlignment="Right"/>
        <ListBox
            x:Name="carListBox"
            Style="{StaticResource StackStyle}"
            Grid.Row="1"
            Grid.Column="1"
            Background="White"
            ItemsSource="{Binding CarList}"
            ScrollViewer.HorizontalScrollBarVisibility="Disabled">
            <ListBox.ItemContainerStyle>
                <Style 
        TargetType="ListBoxItem">
                    <Setter 
            Property="HorizontalContentAlignment"
            Value="Stretch" />
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border 
            BorderThickness="1" 
            BorderBrush="Black" 
            CornerRadius="5">
                        <Grid 
                            Margin="10"
                            HorizontalAlignment="Stretch">

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="64"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="auto"/>
                            </Grid.ColumnDefinitions>
                            <Image
                                Width="64" 
                                Height="64"
                                Source="{Binding ImageBitmap}" />
                            <StackPanel
                                
                                Grid.Column="1"
                                Margin="5"
                                Orientation="Vertical">

                                <TextBlock 
                                    Text="{Binding name}"/>

                                <TextBlock 
                                    Text="{Binding price}"/>
                                
                            </StackPanel>
                            
                            <TextBlock 
                                Grid.Column="2"
                                Text="{Binding year}"/>
                        </Grid>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <StackPanel 
        Orientation="Vertical"
        Grid.RowSpan="3"
        VerticalAlignment="Bottom">
            <Button 
                Background="LightSeaGreen"
            x:Name="ExitButton"
            Content="Выход" 
            Click="ExitButton_Click"
            Height="50"/>
        </StackPanel>
        <WrapPanel  
        Orientation="Horizontal"
        Grid.Column="1"
        MinHeight="50">
            <Button Content="Переключить вид" Click="ToggleView_Click"/>
            <Label 
    Content="Поиск" 
    VerticalAlignment="Center"/>
            <TextBox
    Width="200"
    VerticalAlignment="Center"
    x:Name="SearchFilterTextBox" 
    KeyUp="SearchFilter_KeyUp"/>

            <Label 
    Content="Название:"
    VerticalAlignment="Center"/>

            <ComboBox
                Name="carnameFilterComboBox"
    SelectionChanged="carnameFilterComboBox_SelectionChanged"
    VerticalAlignment="Center"
    MinWidth="100"
    SelectedIndex="0"
    ItemsSource="{Binding CarinfoList}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <Label
                Content="{Binding title}"/>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <Label 
Content="Цена:"
VerticalAlignment="Center"/>

            <ComboBox
Name="carpriceFilterComboBox"
SelectionChanged="carpriceFilterComboBox_SelectionChanged"
VerticalAlignment="Center"
MinWidth="100"
SelectedIndex="0"
ItemsSource="{Binding CarpriceList}">

                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <Label 
            Content="{Binding title}"/>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            <Label 
    Content="Возраст:" 
    VerticalAlignment="Center"/>

            <RadioButton
    GroupName="Age"
    Tag="1"
    Content="по возрастанию"
    IsChecked="True"
    Checked="RadioButton_Checked"
    VerticalAlignment="Center"/>
            <RadioButton
    GroupName="Age"
    Tag="2"
    Content="по убыванию"
    Checked="RadioButton_Checked"
    VerticalAlignment="Center"/>
        </WrapPanel>
    </Grid>
</Window>