<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="PdfCreator.FileOpenPickerPage1"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:PdfCreator"
    xmlns:common="using:PdfCreator.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:ExtensionType="FileOpenPicker">

    <Page.Resources>
        <CollectionViewSource x:Name="filesViewSource" Source="{Binding Files}"/>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the command area
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="80"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Horizontal scrolling grid of files fills the remainder -->
        <GridView
            x:Name="fileGridView"
            AutomationProperties.AutomationId="FileGridView"
            AutomationProperties.Name="Files"
            Grid.RowSpan="2"
            ItemsSource="{Binding Source={StaticResource filesViewSource}}"
            ItemTemplate="{StaticResource StandardFileWithTooltip190x130ItemTemplate}"
            SelectionMode="Multiple"
            SelectionChanged="FileGridView_SelectionChanged"
            Padding="116,76,116,20"/>

        <!-- Command area -->
        <StackPanel x:Name="commandPanel" Orientation="Horizontal" Margin="120,20,120,30">
            <Button
                AutomationProperties.AutomationId="GoUpButton"
                AutomationProperties.Name="Go Up"
                Click="GoUpButton_Click"
                IsEnabled="{Binding CanGoUp}"
                Margin="-3,-3,35,0"
                Style="{StaticResource TextSecondaryButtonStyle}">
                <TextBlock Text="Go Up" Margin="3,-7,3,10" Style="{StaticResource GroupHeaderTextStyle}" />
            </Button>
        </StackPanel>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="fileGridView" Storyboard.TargetProperty="Padding">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="96,76,86,56"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="commandPanel" Storyboard.TargetProperty="Margin">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="100,20,90,30"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
