<UserControl
    x:Class="PDF_Office.Views.BOTA.BookmarkContent"
    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:local="clr-namespace:PDF_Office.Views.BOTA"
    xmlns:convert="clr-namespace:PDF_Office.DataConvert"
    xmlns:data ="clr-namespace:ComPDFKit.PDFDocument;assembly=ComPDFKit.Desk"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:prism="http://prismlibrary.com/"
    d:DesignHeight="450"
    d:DesignWidth="300"
    prism:ViewModelLocator.AutoWireViewModel="True"
    mc:Ignorable="d">
    <UserControl.Resources>
        <ControlTemplate x:Key="textbox" TargetType="{x:Type TextBoxBase}">
            <Border BorderThickness="{TemplateBinding Border.BorderThickness}"
                    BorderBrush="{TemplateBinding Border.BorderBrush}"
                    Background="{TemplateBinding Panel.Background}"
                    Name="border"
                    SnapsToDevicePixels="True">
                <ScrollViewer HorizontalScrollBarVisibility="Hidden"
                              VerticalScrollBarVisibility="Hidden"
                              Name="PART_ContentHost"
                              Focusable="False" />
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="UIElement.IsEnabled"
                         Value="False">
                    <Setter Property="UIElement.Opacity"
                            TargetName="border"
                            Value="0.56" />
                </Trigger>
                <Trigger Property="UIElement.IsMouseOver"
                         Value="True">
                    <Setter Property="Border.BorderBrush"
                            TargetName="border"
                            Value="#FF477EDE" />
                    <Setter Property="Border.Background" TargetName="border" Value="White" />
                </Trigger>
                <Trigger Property="UIElement.IsFocused" Value="True">
                    <Setter Property="Border.Background" TargetName="border" Value="White" />
                    <Setter Property="Border.BorderBrush"
                            TargetName="border"
                            Value="#FF477EDE" />
                </Trigger>
                <Trigger Property="UIElement.IsKeyboardFocused"
                         Value="True">
                    <Setter Property="Border.BorderBrush"
                            TargetName="border"
                            Value="#569DE5" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>

        <convert:BoolToVisible x:Key="BoolToVisibleConvert" />
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="40" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid MinWidth="190">
            <TextBlock x:Name="TxtTitle" HorizontalAlignment="Left" Margin="12,0,0,0" Text="Bookmarks" VerticalAlignment="Center" FontSize="18" FontWeight="SemiBold" />
            <Button Name="BtnSort" HorizontalAlignment="Right" Margin="0,0,0,0" Width="40" Height="40" Content="添加">
            </Button>
        </Grid>
        <Grid Grid.Row="1">
            <ListView Name="BookMarkListView"
                      ItemsSource="{Binding Bookmarklist}"
                      BorderThickness="0"
                      ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                      HorizontalContentAlignment="Stretch"
                      VirtualizingPanel.IsVirtualizing="True"
                      VirtualizingPanel.CacheLengthUnit="Page"
                      VirtualizingPanel.CacheLength="1"
                      VirtualizingPanel.ScrollUnit="Pixel">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <VirtualizingStackPanel Background="White" Margin="-5,0,0,0"></VirtualizingStackPanel>
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>
                <ListView.ItemTemplate>
                    <HierarchicalDataTemplate DataType="{x:Type data:CPDFBookmark}">
                        <StackPanel>
                            <TextBox Name="TitleInput" Grid.Row="1"   Background="Transparent" BorderBrush="Transparent"  VerticalAlignment="Top" FontSize="14" Margin="88,0,0,0" Padding="0,0,18,0" BorderThickness="2" Text="{Binding Title}" Visibility="Visible" />
                            <TextBlock x:Name="btnClear" Grid.Row="1"  HorizontalAlignment="Right" Width="16" Height="16" Margin="0,0,3,0" Visibility="{Binding ElementName=TitleInput, Path=IsFocused, Converter={StaticResource BoolToVisibleConvert}}">
                            </TextBlock>
                        </StackPanel>
                    </HierarchicalDataTemplate>
                </ListView.ItemTemplate>
                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <!--<EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListViewItem_PreviewMouseLeftButtonDown" />
                        <EventSetter Event="Unselected" Handler="ListViewItem_Unselected" />-->
                    </Style>
                </ListView.ItemContainerStyle>
            </ListView>
        </Grid>
        <StackPanel Name="EmptyPanel" Visibility="{Binding IsEmptyPanelVisibility}" Width="150" VerticalAlignment="Center" Grid.RowSpan="2">
            <Image Width="140" Height="140" Source="\Resources\BOTA\empty_bookmark.png" />
            <TextBlock Name="txtEmpty" Text="No bookmark" Margin="0,12,0,0" TextAlignment="Center" FontFamily="Segoe UI" FontSize="16" />
        </StackPanel>
    </Grid>
</UserControl>