<local:MusicContentPage
    x:Class="was.touchcopy.features.music.MusicContentAlbumsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:was.touchcopy.features.music"
    xmlns:data="using:was.touchcopy.features.music.data"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:converters="using:was.touchcopy.features.music.converters"
    xmlns:coreconverters="using:was.touchcopy.features.converters"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
    NavigationCacheMode="Enabled">
    <Page.Resources>
        <ResourceDictionary>
            <converters:BoolToOpacitiyForMediaConverter x:Key="BoolToOpacitiyForMediaConverter" />
            <coreconverters:ValueToVisibilityConverter x:Key="ValueToVisibilityConverter" />
        </ResourceDictionary>
    </Page.Resources>
    <Grid>
        <GridView x:Name="gridViewAlbums" ItemsSource="{x:Bind AlbumData.View, Mode=OneWay}" SelectionMode="Extended"
                  PreviewKeyDown="GridViewAlbums_PreviewKeyDown" ContainerContentChanging="GridViewAlbums_ContainerContentChanging">
            <GridView.GroupStyle>
                <GroupStyle HidesIfEmpty="True">
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate x:DataType="data:AlbumGroup">
                            <TextBlock Text="{Binding Key}" Foreground="{ThemeResource SystemAccentColor}" />
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </GridView.GroupStyle>
            <GridView.ItemTemplate>
                <DataTemplate x:DataType="data:Album">
                    <StackPanel Padding="5" MaxWidth="170" Height="220" IsDoubleTapEnabled="True" DoubleTapped="GridViewAlbums_DoubleTapped" DataContext="{x:Bind}" Background="#00FFFFFF">
                        <Border Width="150" Height="150" BorderThickness="1" BorderBrush="{ThemeResource TextFillColorDisabledBrush}" CornerRadius="8" Background="{ThemeResource TextFillColorInverse}" PointerEntered="Border_PointerEntered" PointerExited="Border_PointerExited">
                            <Grid>
                                <FontIcon x:Name="placeholderFontIcon" Glyph="&#xE93C;" FontSize="28" Opacity=".8" />
                                <Image x:Name="artworkImage" Width="150" Height="150" Opacity="{x:Bind ContainsOnlyRemoteTracks, Converter={StaticResource BoolToOpacitiyForMediaConverter}}"/>
                                <Border x:Name="albumPlayButton" HorizontalAlignment="Right" VerticalAlignment="Bottom" Padding="10" Margin="10" CornerRadius="64" Background="{ThemeResource TextFillColorInverse}" Visibility="Collapsed" Tapped="AlbumPlayButton_Tapped" DataContext="{x:Bind}">
                                    <FontIcon Glyph="&#xE768;" />
                                </Border>
                                <Border HorizontalAlignment="Left" VerticalAlignment="Top" Padding="8,8,10,8" CornerRadius="0,0,12,0" Background="{ThemeResource TextFillColorInverse}" Visibility="{x:Bind ContainsOnlyRemoteTracks, Converter={StaticResource ValueToVisibilityConverter}}">
                                    <FontIcon Glyph="&#xE753;" FontSize="16" FontWeight="Bold" Foreground="{ThemeResource TextFillColorPrimary}">
                                        <ToolTipService.ToolTip>
                                            <ToolTip x:Uid="AlbumIsRemoteToolTip" />
                                        </ToolTipService.ToolTip>
                                    </FontIcon>
                                </Border>
                            </Grid>
                        </Border>
                        <TextBlock Text="{x:Bind Name}" TextWrapping="WrapWholeWords" MaxLines="2" TextTrimming="CharacterEllipsis" FontWeight="SemiBold" FontSize="14" Margin="5,2,5,0" />
                        <TextBlock Text="{x:Bind AlbumArtist}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" Opacity=".7" FontSize="12" Margin="5,2,5,0" />
                        <StackPanel.ContextFlyout>
                            <MenuFlyout Opening="GridViewItemMenuFlyout_Opening">
                                <MenuFlyoutItem x:Uid="MenuFlyoutItemPlay" Text="Play" Click="GridViewMenuPlay_Click">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon Glyph="&#xE768;" />
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                                <MenuFlyoutSeparator />
                                <MenuFlyoutItem x:Uid="MenuFlyoutItemCopy" Text="Copy" Click="GridViewMenuCopyToPC_Click">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon Glyph="&#xE8C8;" />
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                                <MenuFlyoutItem Name="MenuFlyoutItemITunes" x:Uid="MenuFlyoutItemITunes" Text="iTunes" Click="GridViewMenuCopyToITunes_Click">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon Glyph="&#xE90B;" />
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                                <MenuFlyoutItem Name="MenuFlyoutItemAppleMusic" x:Uid="MenuFlyoutItemAppleMusic" Text="AppleMusic" Click="GridViewMenuCopyToAppleMusic_Click">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon Glyph="&#xE90B;" />
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                            </MenuFlyout>
                        </StackPanel.ContextFlyout>
                    </StackPanel>
                </DataTemplate>
            </GridView.ItemTemplate>
        </GridView>
        <Grid x:Name="gridNoResults"  Visibility="Collapsed">
            <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
                <TextBlock x:Name="textBlockNoResults" x:Uid="TextBlockNoResultsAlbums" Text="No results found." FontSize="18" FontStyle="Italic" FontWeight="SemiLight" Opacity=".7"/>
            </StackPanel>
        </Grid>
        <ContentDialog x:Name="contentDialogInvalidOperation" x:Uid="ContentDialogInvalidOperation" CloseButtonText="Dismiss" DefaultButton="Close">
            <TextBlock x:Name="textBlockInvalidOperation" TextWrapping="Wrap" />
        </ContentDialog>
    </Grid>
</local:MusicContentPage>
