<UserControl x:Class="PDFTron.SilverDox.Samples.AnnotationNavigatorControl"
    x:Name="annotationNavigationUserControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:localControl="clr-namespace:PDFTron.SilverDox.Samples.Controls"
    xmlns:controlsInputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit" 
    xmlns:util="clr-namespace:PDFTron.SilverDox.Samples.Utility"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400"
    KeyDown="annotationNavigationUserControl_KeyDown" >

    <UserControl.Resources>
        <ResourceDictionary Source="/ReaderControl;component/Resources/ResourceDictionary.xaml"/>
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Border Grid.Row="0" Style="{StaticResource AnnotationTitleBorderStyle}">
            <TextBlock Text="Annotations List" Style="{StaticResource AnnotationWindowTitleTextBlockStyle}"/>
        </Border>

        <localControl:AnnotationsListBox  x:Name="annotationsListBox" 
                                          Grid.Row="1"
                                          SelectionMode="Extended" >

            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalAlignment" Value="Stretch"/>
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Border BorderThickness="1" CornerRadius="2" BorderBrush="Gray" HorizontalAlignment="Stretch" Padding="5">
                        <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch">
                            <TextBlock>
                                <Run Text="{Binding Path=Subject}"/>
                                <Run Text=", Page: "/>
                                <Run Text="{Binding Path=PageNumber}"/>
                            </TextBlock>
                            <TextBlock Visibility="{Binding Path=Author, Converter={StaticResource HideIfNullConverter}}">
                                <Run Text="Author: "/>
                                <Run Text="{Binding Path=Author}"/>
                            </TextBlock>
                            <TextBlock TextWrapping="Wrap" Visibility="{Binding Path=PopupContents, Converter={StaticResource HideIfNullConverter}}">
                                <Run FontStyle="Italic"  Text="{Binding Path=PopupContents}"/>
                            </TextBlock>

                            <controlsInputToolkit:ContextMenuService.ContextMenu>
                                <controlsInputToolkit:ContextMenu x:Name="annotationListContextMenu" Opened="annotationListContextMenu_Opened">
                                    <controlsInputToolkit:MenuItem x:Name="removeAnnotationMenuItem" 
                                                                   Header="Remove" 
                                                                   Command="{Binding RemoveAnnotationCommand, ElementName=annotationNavigationUserControl}"/>
                                </controlsInputToolkit:ContextMenu>
                            </controlsInputToolkit:ContextMenuService.ContextMenu>

                        </StackPanel>
                    </Border>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </localControl:AnnotationsListBox>
    </Grid>
</UserControl>
