<UserControl
    x:Class="PicView.WPF.Views.UserControls.Gallery.PicGallery"
    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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:buttons="clr-namespace:PicView.WPF.Views.UserControls.Buttons"
    xmlns:uiLogic="clr-namespace:PicView.WPF.UILogic"
    d:DesignHeight="300"
    d:DesignWidth="300"
    mc:Ignorable="d">
    <Border
        x:Name="border"
        Background="{StaticResource BackgroundColorBrushFade}"
        BorderBrush="{StaticResource BorderBrush}"
        BorderThickness="1,0,1,0">
        <Grid x:Name="grid">
            <buttons:X2
                x:Name="x2"
                HorizontalAlignment="Right"
                VerticalAlignment="Top"
                Panel.ZIndex="1" />
            <uiLogic:SmoothScrollViewer
                x:Name="Scroller"
                CanContentScroll="True"
                FocusVisualStyle="{x:Null}"
                Focusable="False"
                HorizontalScrollBarVisibility="Visible"
                IsDeferredScrollingEnabled="False"
                VerticalScrollBarVisibility="Disabled">
                <uiLogic:SmoothScrollViewer.Style>
                    <Style TargetType="{x:Type ScrollViewer}">
                        <Setter Property="OverridesDefaultStyle" Value="True" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="Auto" />
                                        </Grid.RowDefinitions>
                                        <ScrollContentPresenter Grid.RowSpan="2" Grid.ColumnSpan="2" />
                                        <ScrollBar
                                            Name="PART_VerticalScrollBar"
                                            Grid.Column="1"
                                            HorizontalAlignment="Right"
                                            Maximum="{TemplateBinding ScrollableHeight}"
                                            ViewportSize="{TemplateBinding ViewportHeight}"
                                            Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                            Value="{TemplateBinding VerticalOffset}" />
                                        <ScrollBar
                                            Name="PART_HorizontalScrollBar"
                                            Grid.Row="1"
                                            VerticalAlignment="Bottom"
                                            Maximum="{TemplateBinding ScrollableWidth}"
                                            Orientation="Horizontal"
                                            ViewportSize="{TemplateBinding ViewportWidth}"
                                            Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                            Value="{TemplateBinding HorizontalOffset}" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </uiLogic:SmoothScrollViewer.Style>
                <WrapPanel
                    x:Name="Container"
                    Background="Transparent"
                    FocusVisualStyle="{x:Null}"
                    Focusable="False"
                    Orientation="Vertical"
                    VirtualizingPanel.VirtualizationMode="Recycling" />
            </uiLogic:SmoothScrollViewer>
        </Grid>
    </Border>
</UserControl>