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

    <Page.Resources>
        <common:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
        <common:BooleanNegationConverter x:Key="BooleanNegationConverter"/>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines three rows:
        * Row 0 contains the standard share target header
        * Row 1 contains a TextBox for adding a Comment
        * Row 2 contains the standard share target footer
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid Margin="40,20,40,60">
            <Grid.RowDefinitions>
                <RowDefinition Height="180"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <!-- The standard share target header displays metadata about the shared item -->
            <Image
                Source="{Binding Image}"
                Stretch="Uniform"
                Visibility="{Binding ShowImage, Converter={StaticResource BooleanToVisibilityConverter}}"
                VerticalAlignment="Top"				
                MinWidth="80"
                MinHeight="80"
                MaxWidth="240"
                MaxHeight="160"
                Margin="0,0,20,0"/>
            <StackPanel Grid.Column="1">
                <TextBlock
                    Text="{Binding Title}"
                    Margin="0,-10,0,20"
                    TextWrapping="NoWrap"
                    Foreground="{StaticResource ApplicationSecondaryForegroundThemeBrush}"
                    Style="{StaticResource SubheaderTextStyle}"/>
                <TextBlock
                    Text="{Binding Description}"
                    MaxHeight="60"
                    Foreground="{StaticResource ApplicationSecondaryForegroundThemeBrush}"
                    Style="{StaticResource BodyTextStyle}"/>
            </StackPanel>

            <Grid Grid.Row="1" Grid.ColumnSpan="2">
                <StackPanel Visibility="{Binding ShowBlog, Converter={StaticResource BooleanToVisibilityConverter}}"
                            Orientation="Vertical">
                    <HyperlinkButton NavigateUri="{Binding BlogPost.properties.url}"
                                        Content="{Binding BlogPost.properties.headline}"/>
                    <ScrollViewer Height="200">
                        <RichTextBlock Margin="20">
                            <Paragraph>
                                <Run FontWeight="SemiLight" 
                                        FontSize="13" 
                                        Text="{Binding BlogPost.properties.articleBody}"/>
                            </Paragraph>
                        </RichTextBlock>
                    </ScrollViewer>
                </StackPanel>
            </Grid>

          <!-- Standard share target footer -->
            <Grid Grid.Row="2" Grid.ColumnSpan="2">
                <ProgressRing
                    IsActive="{Binding Sharing}"
                    MinWidth="20"
                    MinHeight="20"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Top"
                    Margin="0,5,0,0"/>
                <TextBlock
                    Text="Sharing&#x2026;"
                    Visibility="{Binding Sharing, Converter={StaticResource BooleanToVisibilityConverter}}"
                    HorizontalAlignment="Left"
                    Margin="25,0,0,0"
                    Style="{StaticResource ItemTextStyle}"/>
                <Button
                    AutomationProperties.AutomationId="ShareButton"
                    AutomationProperties.Name="Share"
                    TabIndex="1"
                    Content="Gotowe"
                    IsEnabled="{Binding Sharing, Converter={StaticResource BooleanNegationConverter}}"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Top"
                    Margin="0,10,-3,0"
                    Click="ShareButton_Click"/>
            </Grid>
        </Grid>
    </Grid>
</common:LayoutAwarePage>
