<Page x:Class="TravelAgencyWindow.Pages.ListOfHotelPage"
      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" 
      xmlns:listmodel="clr-namespace:TravelAgencyWindow.Model"
      xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
      mc:Ignorable="d" 
      d:DesignHeight="430" d:DesignWidth="800"
      Title="ListOfHotelPage"
      Background="White">

    <Page.Resources>
        <DataTemplate x:Key="btnUpdateColumn">
            <Button Content="Редактировать" Style="{StaticResource btn_menu}" Tag="{Binding Id}"/>
        </DataTemplate>
    </Page.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>
        <TextBlock Text="Список отелей" Style="{StaticResource txt_deafault}"
                       Margin="10"
                       Foreground="#FF445C93"
                       Grid.Row="0" 
                       HorizontalAlignment="Left" VerticalAlignment="Top"/>
        <StackPanel Grid.Row="0" Orientation="Vertical" Width="300" HorizontalAlignment="Right" Margin="0,10,10,0">
            <StackPanel Orientation="Horizontal">
                <TextBlock VerticalAlignment="Center" Text="Кол-во элементов" Style="{StaticResource txt_main}"/>
                <!--Про переключение кол-во эл-ов-->
                <Grid Width="55" Margin="5">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="13" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="13" />
                        <RowDefinition Height="13" />
                    </Grid.RowDefinitions>
                    <TextBox Text="{Binding CountOnPage, UpdateSourceTrigger=PropertyChanged}"
                            Name="NUDTextBox" 
                             Style="{StaticResource ed_txt_settings}"
                             Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" 
                             TextAlignment="Right"
                             VerticalAlignment="Center"/>
                    <RepeatButton Name="NUDButtonUP"
                                  Grid.Column="1" Grid.Row="0"
                                  Style="{StaticResource rpbtn_settings}"
                                  Click="NUDButtonUP_Click">↑</RepeatButton>
                    <RepeatButton Name="NUDButtonDown"  Height="13" 
                                  Grid.Column="1" Grid.Row="1" 
                                 Style="{StaticResource rpbtn_settings}"
                                  Click="NUDButtonDown_Click">↓</RepeatButton>
                </Grid>
            </StackPanel>
            <!--Перелистывание страниц-->
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="Страница" Style="{StaticResource txt_main}" Margin="2"/>
                <Button x:Name="PageButtonPrew" Content="Назад"
                           MinWidth="60"
                        Style="{StaticResource btn_settings}"
                        Click="PageButtonPrew_Click"/>
                <TextBox Width="30" Text="{Binding PageNumber, UpdateSourceTrigger=PropertyChanged}" 
                           TextAlignment="Center"
                           Style="{StaticResource ed_txt_settings}" Margin="2,2,0,2"/>
                <TextBlock Text="из" Style="{StaticResource txt_settings}" Margin="0,2,0,2" />
                <TextBlock Width="30" Text="{Binding CountPage, StringFormat={}{0}}" 
                           TextAlignment="Center"
                           Style="{StaticResource txt_settings}" Margin="0,2,2,2"/>
                <Button x:Name="PageButtonNext" Content="Вперед" Margin="2"
                           MinWidth="60"
                        Style="{StaticResource btn_settings}"
                        Click="PageButtonNext_Click"/>

            </StackPanel>
        </StackPanel>
        <DataGrid AutoGenerateColumns="False" 
                  CanUserAddRows="False"
                  Grid.Row="1" ItemsSource="{Binding HotelList}" 
                  ColumnHeaderStyle="{StaticResource dtgrid_header}">
            <DataGrid.Columns>
                <DataGridCheckBoxColumn Binding="{Binding IsChecked}"/>
                <DataGridTextColumn IsReadOnly="True" Header="Название" Binding="{Binding Name}" ElementStyle="{StaticResource txt_deafault}"/>
                <DataGridTextColumn IsReadOnly="True" Header="Количество звезд" Binding="{Binding CountOfStars}" ElementStyle="{StaticResource txt_deafault}"/>
                <DataGridTextColumn IsReadOnly="True" Header="Страна" Binding="{Binding Country.Name}" ElementStyle="{StaticResource txt_deafault}"/>
                <DataGridTextColumn IsReadOnly="True" Header="Количество туров" Binding="{Binding Tour.Count}" ElementStyle="{StaticResource txt_deafault}"/>
                <DataGridTemplateColumn CellTemplate="{StaticResource btnUpdateColumn}" />
            </DataGrid.Columns>
        </DataGrid>
    </Grid>
</Page>
