<Page
    x:Name="pageRoot"
    x:Class="SsrsViewerSamples.GroupedItemsPage"
    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:SsrsViewerSamples"
    xmlns:data="using:SsrsViewerSamples.Data"
    xmlns:common="using:SsrsViewerSamples.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>
        <x:String x:Key="ChevronGlyph">&#xE26B;</x:String>
        <!--
            Collection of grouped items displayed by this page, bound to a subset
            of the complete item list because items in groups cannot be virtualized
        -->
        <CollectionViewSource
            x:Name="itemsViewSource"
            Source="{Binding Items}"
            ItemsPath="TopItems"
            d:Source="{Binding Items, Source ={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <!-- Footer -->
        <Image VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="120 20" Grid.Row="2" Source="/Assets/c1logo.png" Width="245" Height="41"/>

        <!-- Horizontal scrolling grid -->
        <GridView
            x:Name="itemGridView"
            AutomationProperties.AutomationId="ItemGridView"
            AutomationProperties.Name="Items"
            Grid.Row="1"
            Margin="0,-3,0,0"
            Padding="116,0,40,46"
            ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
            SelectionMode="None"
            IsSwipeEnabled="false"
            IsItemClickEnabled="True"
            ItemClick="ItemView_ItemClick">
            <GridView.ItemTemplate>
                <DataTemplate >
                    <Grid HorizontalAlignment="Left" Width="150" Height="150">
                        <Border Background="#FF2C383D">
                            <ContentControl ContentTemplate="{Binding Icon}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" Margin="28 16 28 40"/>
                        </Border>
                        <Border VerticalAlignment="Bottom" Height="34">
                            <TextBlock Text="{Binding Name}" Foreground="White" FontFamily="Segoe WP" FontSize="17" VerticalAlignment="Center" TextAlignment="Center"/>
                        </Border>
                    </Grid>
                </DataTemplate>
            </GridView.ItemTemplate>
        </GridView>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Command="{Binding NavigationHelper.GoBackCommand, ElementName=pageRoot}"
                    Margin="36,0,36,36" Height="48" Width="48" FontSize="56"
                        Style="{StaticResource NavigationBackButtonNormalStyle}"
                        VerticalAlignment="Bottom"
                        AutomationProperties.Name="Back"
                        AutomationProperties.AutomationId="BackButton"
                        AutomationProperties.ItemType="Navigation Button"/>
            <StackPanel Grid.Column="1" VerticalAlignment="Center" Orientation="Horizontal">
                <Image Source="/Assets/winrtxamlLogo_64.png" Width="64" Height="64"/>
                <TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Style="{StaticResource HeaderTextBlockStyle}" 
                           Margin="20 0 0 0" VerticalAlignment="Center" IsHitTestVisible="false" TextWrapping="NoWrap"/>
            </StackPanel>
        </Grid>
    </Grid>
</Page>