<controls:PageBase
    x:Class="JumpPoint.Uwp.Views.WslPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:JumpPoint.Uwp.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:JumpPoint.Uwp.Controls"
    xmlns:i="using:Microsoft.Xaml.Interactivity"
    xmlns:icore="using:Microsoft.Xaml.Interactions.Core"
    xmlns:actions="using:NittyGritty.Uwp.Interactivity.Actions"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <controls:JumpPointViewer Grid.Row="1"
                                  Context="{x:Bind ViewModel, Mode=OneWay}"
                                  SortBy="{x:Bind ViewModel.Settings.SortBy, Mode=OneWay}"
                                  IsSortAscending="{x:Bind ViewModel.Settings.IsSortAscending, Mode=OneWay}"
                                  GroupBy="{x:Bind ViewModel.Settings.GroupBy, Mode=OneWay}"
                                  IsGroupAscending="{x:Bind ViewModel.Settings.IsGroupAscending, Mode=OneWay}"
                                  IsLoading="{x:Bind ViewModel.IsLoading, Mode=OneWay}"
                                  SelectedItems="{x:Bind ViewModel.SelectedItems, Mode=OneWay}"
                                  ItemsSource="{x:Bind ViewModel.Items, Mode=OneWay}" />
        <Grid Padding="12,8"
              Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
              x:Load="{x:Bind ViewModel.IsSearching, Mode=OneWay}"
              ColumnSpacing="8"
              x:Name="paneSearch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBox Text="{x:Bind ViewModel.Search, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                     PlaceholderText="Search..."
                     HorizontalAlignment="Stretch">
                <i:Interaction.Behaviors>
                    <icore:EventTriggerBehavior EventName="Loaded">
                        <actions:FocusAction />
                    </icore:EventTriggerBehavior>
                </i:Interaction.Behaviors>
            </TextBox>
            <Button Grid.Column="1"
                    Padding="4"
                    BorderThickness="0"
                    Background="Transparent"
                    VerticalAlignment="Center"
                    Click="{x:Bind ViewModel.CloseSearch}">
                <IconSourceElement IconSource="{StaticResource CloseTabIcon}" />
            </Button>
        </Grid>
    </Grid>
</controls:PageBase>
