<Page x:Class="PracticaDemoexam.Pages.Agents"
      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:PracticaDemoexam.Pages"
      mc:Ignorable="d" 
      d:DesignHeight="450" d:DesignWidth="800"
      Title="Agents">
    <Page.Resources>
        <Style TargetType="ListBoxItem">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=Discount}" Value="25%">
                    <Setter Property="Background" Value="#46B29D"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </Page.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="341*"/>
            <ColumnDefinition Width="248"/>
            <ColumnDefinition Width="211"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="28"/>
            <RowDefinition/>
            <RowDefinition Height="21"/>
        </Grid.RowDefinitions>
        <TextBox x:Name="tbSearch" Grid.Column="0" Grid.Row="0" TextChanged="tbSearch_TextChanged"/>
        <StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="0" MinWidth="248">
            <ComboBox x:Name="cbSort" SelectionChanged="cbSort_SelectionChanged" MinWidth="200"/>
            <StackPanel Orientation="Vertical">
                <RadioButton x:Name="rbUb" Content="убыв" Click="RadioButton_Click"/>
                <RadioButton x:Name="rbVz" Content="возр" Click="RadioButton_Click"/>
            </StackPanel>
        </StackPanel>
        <ComboBox x:Name="cbFilter" Grid.Column="2" Grid.Row="0" SelectionChanged="cbFilter_SelectionChanged"/>
        <ListBox x:Name="lbAgents" Grid.Row="1" Grid.ColumnSpan="3" SelectionMode="Multiple" SelectionChanged="lbAgents_SelectionChanged">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" >
                        <Image Source="{Binding Path=AgentLogo}" Width="100" Height="100"/>
                        <StackPanel Orientation="Vertical">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Path=AgentType}"/>
                                <TextBlock Text="|"/>
                                <TextBlock Text="{Binding Path=Agent.Title}"/>
                            </StackPanel>
                            <TextBlock Text="{Binding Path=YearSales}"/>
                            <TextBlock Text="{Binding Path=Agent.Phone}"/>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Приоритетность: "/>
                                <TextBlock Text="{Binding Path=Agent.Priority}"/>
                            </StackPanel>
                        </StackPanel>
                        <StackPanel HorizontalAlignment="Right" Margin="400,0,0,0">
                            <TextBlock x:Name="tblDiscount" Text="{Binding Path=Discount}"/>
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" HorizontalAlignment="Right" Margin="0,0,10,0">
            <Button x:Name="bLeft" Content="&lt;" Click="bLeft_Click"/>
            <ListBox x:Name="lbPogination" SelectionChanged="lbPogination_SelectionChanged">
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>
            <Button x:Name="bRight" Content=">" Click="bRight_Click"/>
        </StackPanel>
    </Grid>
</Page>
