<!-- Resource Dictionary used to store a Data Template used to 
     display message content Image.This data template will be 
     selected by the MessageContentSelector class if the message 
     content is determined to be of Image type.
     Code behind to process control events are in MessageContentImageDataTemplate.cs 
     You should include a static reference to MessageContentImageDataTemplate on the page where you plan to use
     the DataTemplate MessageContentImageDataTemplate.xaml-->
<ResourceDictionary
    x:Name="resourceDictionary"
    x:Class="was.touchcopy.features.messaging.ux.MessageContentImageDataTemplate"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ux="using:was.touchcopy.features.messaging.ux"
    xmlns:messaging="using:was.touchcopy.features.messaging"
    xmlns:converters="using:was.touchcopy.features.messaging.converters"
    xmlns:commonconverters="using:was.touchcopy.features.converters">

    <converters:MessageContentToImageMaxWidthConverter x:Key="MessageContentToImageMaxWidthConverter"/>
    <converters:MessageContentToImageBackupFileConverter x:Key="MessageContentToImageBackupFileConverter"/>
    <converters:MessageContentToImageHeightConverter x:Key="MessageContentToImageHeightConverter" />
    <converters:MessageContentToImageWidthConverter x:Key="MessageContentToImageWidthConverter" />
    <converters:MessageContentToImageTitleConverter x:Key="MessageContentToImageTitleConverter" />
    <converters:MessageContentAvailabilityToVisibilityConverter x:Key="MessageContentAvailabilityToVisibilityConverter" />
    <commonconverters:VisibilityInverter x:Key="VisibilityInverter" />

    <DataTemplate x:Key="MessageContentImageDataTemplate" x:DataType="messaging:MessageContent">
        <Border x:Name="templateBorder" Tag="{Binding Converter={StaticResource MessageContentToImageTitleConverter} }" Padding="0"  Margin="0,0,0,0" CornerRadius="{ThemeResource HyperlinkFocusRectCornerRadius}" Background="Transparent"
                Height="{Binding Converter={StaticResource MessageContentToImageHeightConverter}}" 
                Width="{Binding Converter={StaticResource MessageContentToImageWidthConverter}}"
                MaxWidth="{Binding Converter={StaticResource MessageContentToImageMaxWidthConverter}}">

            <Grid>
                <Grid x:Name="gridContent" PointerEntered="PointerEnteredGrid" PointerExited="PointerExitedGrid" Visibility="{Binding Converter={StaticResource MessageContentAvailabilityToVisibilityConverter}, Mode=OneTime}">
                    <ux:BackupFileImageControl x:Name="image" BackupFile="{x:Bind Converter={StaticResource MessageContentToImageBackupFileConverter}, Mode=OneTime}" 
               DoubleTapped="PreviewClick" Tag="{Binding Converter={StaticResource MessageContentToImageTitleConverter}}" Stretch="Uniform">
                        <ux:BackupFileImageControl.ContextFlyout>
                            <MenuFlyout>
                                <MenuFlyoutItem x:Uid="MenuFlyoutSaveToPC" Text="Save to PC" Click="SaveToPCClick" Tag="{Binding}">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon Glyph="&#xE78C;"/>
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                                <MenuFlyoutItem x:Uid="MenuFlyoutPreview" Text="Preview" Click="PreviewClick" Tag="{Binding ElementName=image, Mode=OneWay}">
                                    <MenuFlyoutItem.Icon>
                                        <FontIcon Glyph="&#xE890;"/>
                                    </MenuFlyoutItem.Icon>
                                </MenuFlyoutItem>
                            </MenuFlyout>
                        </ux:BackupFileImageControl.ContextFlyout>
                    </ux:BackupFileImageControl>
                    <Border x:Name="borderControls" Visibility="Collapsed" HorizontalAlignment="Right" VerticalAlignment="Top" Background="{ThemeResource TextFillColorInverse}" Padding="3" Margin="5" CornerRadius="6">
                        <StackPanel Orientation="Horizontal">
                            <Button Click="SaveToPCButton_Click" BorderThickness="0" Background="Transparent" CornerRadius="4,0,0,4" Foreground="{ThemeResource TextFillColorPrimary}">
                                <FontIcon Glyph="&#xE78C;" />
                                <ToolTipService.ToolTip>
                                    <ToolTip x:Uid="SaveToPCToolTip" Content="Save to PC" />
                                </ToolTipService.ToolTip>
                            </Button>
                            <AppBarSeparator />
                            <Button Click="PreviewButton_Click" BorderThickness="0" Background="Transparent" CornerRadius="0,4,4,0" Foreground="{ThemeResource TextFillColorPrimary}">
                                <FontIcon Glyph="&#xE890;" />
                                <ToolTipService.ToolTip>
                                    <ToolTip x:Uid="PreviewToolTip" Content="Preview" />
                                </ToolTipService.ToolTip>
                            </Button>
                        </StackPanel>
                    </Border>
                </Grid>
                <Grid Visibility="{Binding Visibility, ElementName=gridContent, Converter={StaticResource VisibilityInverter}, Mode=OneWay}" ColumnSpacing="12">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <StackPanel VerticalAlignment="Center">
                        <TextBlock x:Uid="TextBlockImageUnavailable" Text="XX Image unavailable." Style="{ThemeResource BodyStrongTextBlockStyle}"/>
                        <TextBlock x:Uid="TextBlockAttachmentNotStoredOnDevice" Text="XX It may not be stored on your device." Style="{ThemeResource CaptionTextBlockStyle}"/>
                    </StackPanel>
                    <HyperlinkButton x:Uid="HyperlinkButtonAttachmentUnavailable" VerticalAlignment="Center" Grid.Column="1" CornerRadius="16" Padding="4">
                        <FontIcon Glyph="&#xE897;" />
                    </HyperlinkButton>
                </Grid>
            </Grid>
        </Border>
    </DataTemplate>
</ResourceDictionary>
