<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Style x:Key="FocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="2" StrokeDashArray="1 2" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" SnapsToDevicePixels="true" StrokeThickness="1"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <SolidColorBrush x:Key="Item.MouseOver.Background" Color="#1F26A0DA"/>
    <SolidColorBrush x:Key="Item.MouseOver.Border" Color="#1460F3"/>
    <SolidColorBrush x:Key="Item.SelectedActive.Background" Color="#3D26A0DA"/>
    <SolidColorBrush x:Key="Item.SelectedActive.Border" Color="#FF26A0DA"/>
    <SolidColorBrush x:Key="Item.SelectedInactive.Background" Color="#3DDADADA"/>
    <SolidColorBrush x:Key="Item.SelectedInactive.Border" Color="#FFDADADA"/>
    <SolidColorBrush x:Key="Item.Selected.Text" Color="#FFFFFF"/>

    <Style x:Key="ThumbnailListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Padding" Value="4,1"/>
        <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">

                        <StackPanel HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
                            <Viewbox Margin="0,5,0,0" Stretch="Uniform" Width="{Binding ThumbnailWidth}" Height="{Binding ThumbnailHeight}">
                                <Border x:Name="imageOuterBorder" BorderThickness="2" BorderBrush="Transparent">
                                    <Border x:Name="imageInnerBorder" BorderThickness="2" BorderBrush="Black">
                                        <Image Source="{Binding Path=ImageData.Source}" Margin="0,0,5,0" Width="{Binding ImageWidth}" Height="{Binding ImageHeight}"></Image>
                                    </Border>
                                </Border>
                            </Viewbox>

                            <Border x:Name="pageNumberBorder" Width="22" Height="16" Margin="0,8,0,0">
                                <TextBlock x:Name="pageNumberText" Text="{Binding ShowPageText}" HorizontalAlignment="Center" FontSize="11" VerticalAlignment="Center"></TextBlock>
                            </Border>

                        </StackPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" TargetName="imageOuterBorder" Value="{StaticResource Item.MouseOver.Border}"/>
                            <Setter Property="BorderBrush" TargetName="imageInnerBorder" Value="{StaticResource Item.MouseOver.Border}"/>
                            <Setter Property="Background" TargetName="pageNumberBorder" Value="{StaticResource Item.MouseOver.Border}"/>
                            <Setter Property="Foreground" TargetName="pageNumberText" Value="{StaticResource Item.Selected.Text}"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="Selector.IsSelectionActive" Value="False"/>
                                <Condition Property="IsSelected" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" TargetName="imageOuterBorder" Value="{StaticResource Item.MouseOver.Border}"/>
                            <Setter Property="BorderBrush" TargetName="imageInnerBorder" Value="{StaticResource Item.MouseOver.Border}"/>
                            <Setter Property="Background" TargetName="pageNumberBorder" Value="{StaticResource Item.MouseOver.Border}"/>
                            <Setter Property="Foreground" TargetName="pageNumberText" Value="{StaticResource Item.Selected.Text}"/>
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="Selector.IsSelectionActive" Value="True"/>
                                <Condition Property="IsSelected" Value="True"/>
                            </MultiTrigger.Conditions>
                            <Setter Property="BorderBrush" TargetName="imageOuterBorder" Value="{StaticResource Item.MouseOver.Border}"/>
                            <Setter Property="BorderBrush" TargetName="imageInnerBorder" Value="{StaticResource Item.MouseOver.Border}"/>
                            <Setter Property="Background" TargetName="pageNumberBorder" Value="{StaticResource Item.MouseOver.Border}"/>
                            <Setter Property="Foreground" TargetName="pageNumberText" Value="{StaticResource Item.Selected.Text}"/>
                        </MultiTrigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <ControlTemplate x:Key="ListBoxItemControlTemplate" TargetType="{x:Type ListBoxItem}">
        <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
            <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
        </Border>
        <ControlTemplate.Triggers>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsMouseOver" Value="True"/>
                </MultiTrigger.Conditions>
                <Setter Property="Background" TargetName="Bd" Value="#1A000000"/>
                <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="Selector.IsSelectionActive" Value="False"/>
                    <Condition Property="IsSelected" Value="True"/>
                </MultiTrigger.Conditions>
                <Setter Property="Background" TargetName="Bd" Value="#1A477EDE"/>
                <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="Selector.IsSelectionActive" Value="True"/>
                    <Condition Property="IsSelected" Value="True"/>
                </MultiTrigger.Conditions>
                <Setter Property="Background" TargetName="Bd" Value="#1A477EDE"/>
                <Setter Property="BorderBrush" TargetName="Bd" Value="Transparent"/>
            </MultiTrigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="TextElement.Foreground" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>
</ResourceDictionary>