<Page x:Class="TravelAgencyWindow.Pages.ListOfTourPage"
      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:TravelAgencyWindow.Pages" 
      mc:Ignorable="d" 
      d:DesignHeight="410" d:DesignWidth="830"
      Title="ListOfTourPage"
      Name="listOfTourPage">

    <Page.Resources>
        <DataTemplate x:Key="viewItemListTour">
            <StackPanel Width="250" Orientation="Vertical" HorizontalAlignment="Center">
                
                <TextBlock Text="{Binding Name}" Style="{StaticResource txt_header}" 
                           MaxWidth="200" TextWrapping="Wrap" HorizontalAlignment="Center"/>
                
                <Image Height="200" Source="{Binding ImageOnView}" HorizontalAlignment="Center"/>
                
                <TextBlock HorizontalAlignment="Center" Text="{Binding Price, StringFormat={}{0} РУБ.}" TextAlignment="Center" Style="{StaticResource txt_for_ettention}"/>
               
                <DockPanel >
                    <TextBlock Text="{Binding IsActualOnString}" DockPanel.Dock="Left">
                        <TextBlock.Style>
                            <Style TargetType="TextBlock" BasedOn="{StaticResource txt_deafault}">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding IsActualOnString}" Value="Актуален">
                                        <Setter Property="Foreground" Value="Green"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding IsActualOnString}" Value="Не актуален">
                                        <Setter Property="Foreground" Value="DarkRed"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                    <TextBlock DockPanel.Dock="Right" Text="{Binding TicketCount, StringFormat=Билетов: {0}}" TextAlignment="Right" Style="{StaticResource txt_deafault}"/>
                </DockPanel>
                
            </StackPanel>
        </DataTemplate>
        <!--Для определения в каком виде компановки будет список-->
        <ItemsPanelTemplate x:Key="viewTileList">
            <!--Если столбцы-->
            <!--<UniformGrid Columns="3" />-->
            <WrapPanel Width="{Binding ElementName=listOfTourPage, Path=ActualWidth}" />
        </ItemsPanelTemplate>
    </Page.Resources>



    <Grid>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="1*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="120"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            
            <TextBlock Text="Список туров:" Style="{StaticResource txt_deafault}"
                       Margin="10"
                       Foreground="#FF445C93"
                       Grid.Row="0" Grid.Column="0"
                       HorizontalAlignment="Left" VerticalAlignment="Top"/>
            
            <TextBlock Text="{Binding SummaryPrice,StringFormat=Общая стоимость туров: {0:F0}}" 
                       TextWrapping="WrapWithOverflow"
                       Grid.Row="0" Grid.Column="1"
                       HorizontalAlignment="Right" VerticalAlignment="Top"
                       Style="{StaticResource txt_deafault}"/>
            
            <StackPanel Width="400" Grid.Row="0" Grid.ColumnSpan="2" Orientation="Vertical" 
                        HorizontalAlignment="Center" VerticalAlignment="Center">
                
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <TextBlock Text="Введите текст для поиска: " Style="{StaticResource txt_deafault}"/>
                    <TextBox Margin="5" Width="150" Text="{Binding NameTour, Mode=TwoWay}" Style="{StaticResource ed_txt_deafault}" TextChanged="Find_TextChanged"/>
                </StackPanel>
                
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <TextBlock Text="Выберите тип: " Style="{StaticResource txt_deafault}"/>
                    <ComboBox Width="150" ItemsSource="{Binding Types}" SelectedValuePath="Id" DisplayMemberPath="Name" SelectedValue="{Binding TypeViewId}"/>
                </StackPanel>
                
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <TextBlock Text="По цене: " Style="{StaticResource txt_deafault}"/>
                    <ComboBox Width="150" ItemsSource="{Binding CatSortingByPrice}" SelectedValuePath="Id" DisplayMemberPath="Name" SelectedValue="{Binding IdSorting}"/>
                </StackPanel>
                
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                    <CheckBox IsChecked="{Binding CheckIsActual, Mode=TwoWay}" VerticalAlignment="Center"/>
                    <TextBlock Text="только актуальные типы " Style="{StaticResource txt_deafault}" VerticalAlignment="Center"/>
                </StackPanel>
            </StackPanel>
            
            <ListBox HorizontalAlignment="Left" 
                     Width="{Binding ElementName=listOfTourPage, Path=ActualWidth}" 
                     Grid.Row="1" Grid.ColumnSpan="2"
                     ItemTemplate="{StaticResource viewItemListTour}" 
                     ItemsSource="{Binding CurrentTours}" 
                     ItemsPanel="{StaticResource viewTileList}" />
        </Grid>
    </Grid>
</Page>
