<Page
    x:Class="was.touchcopy.features.photos.PhotosContentPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:was.touchcopy.features.photos"
    xmlns:featurebase="using:was.touchcopy.features"
    xmlns:coreconverters="using:was.touchcopy.features.converters"
    xmlns:data="using:was.touchcopy.features.photos.data"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DataContext="{d:DesignInstance Type=local:PhotosContentPage}"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Page.Resources>
        <ResourceDictionary>
            <coreconverters:ValueToVisibilityConverter x:Key="ValueToVisibilityConverter" />
        </ResourceDictionary>
    </Page.Resources>
    <Border Style="{ThemeResource FeatureContentPageBorder}" Padding="0">
        <Grid >
            <Grid x:Name="gridLoading" Visibility="{x:Bind IsLoading, Mode=OneWay}">
                <StackPanel VerticalAlignment="Center">
                    <TextBlock x:Uid="TextBlockLoadingMedia" Text="XX Loading Media..." Style="{ThemeResource TitleTextBlockStyle}" TextAlignment="Center" TextWrapping="Wrap" />
                    <ProgressRing IsIndeterminate="{x:Bind IsLoading, Mode=OneWay}" Margin="0,20,0,0" />
                </StackPanel>
            </Grid>
            <Grid x:Name="gridContent" Visibility="{x:Bind IsLoading, Converter={StaticResource ValueToVisibilityConverter}, ConverterParameter=invert, Mode=OneWay}">
                <GridView x:Name="itemsGridView" ItemsSource="{x:Bind PhotoItems, Mode=OneWay}" SelectionMode="Extended"
                      IsDoubleTapEnabled="True" DoubleTapped="ItemsGridView_DoubleTapped" PreviewKeyDown="ItemsGridView_PreviewKeyDown"
                      ContainerContentChanging="ItemsGridView_ContainerContentChanging">
                    <GridView.ItemTemplate>
                        <DataTemplate x:DataType="data:PhotosItem" >
                            <Grid Width="128" Height="128">
                                <local:PhotosThumbnailControl x:Name="thumbnailControl" Width="128" Height="128" />
                            </Grid>
                        </DataTemplate>
                    </GridView.ItemTemplate>
                    <GridView.ContextFlyout>
                        <MenuFlyout>
                            <MenuFlyoutItem x:Uid="MenuFlyoutItemPreview" Text="XX Preview" Click="AppBarButtonView_Click">
                                <MenuFlyoutItem.Icon>
                                    <FontIcon Glyph="&#xE890;" />
                                </MenuFlyoutItem.Icon>
                            </MenuFlyoutItem>
                            <MenuFlyoutItem x:Uid="MenuFlyoutItemSaveToPC" Text="XX Save to PC" Click="AppBarButtonSave_Click">
                                <MenuFlyoutItem.Icon>
                                    <FontIcon Glyph="&#xE78C;" />
                                </MenuFlyoutItem.Icon>
                            </MenuFlyoutItem>
                        </MenuFlyout>
                    </GridView.ContextFlyout>
                </GridView>
            </Grid>
            <featurebase:ImagePreviewPage x:Name="imagePreviewPage" Visibility="Collapsed" Padding="30"/>
        </Grid>
    </Border>
</Page>
