<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ui="http://schemas.modernwpf.com/2019"
                    xmlns:utils="clr-namespace:ModernFlyouts.Utilities"
                    xmlns:converters="clr-namespace:ModernFlyouts.Converters">

    <converters:ScrollButtonVisibilityConverter x:Key="ScrollButtonVisibilityConverter" />

    <!--region: ScrollViewer-->

    <ControlTemplate x:Key="SecondaryContentScrollBarButtonTemplate" TargetType="Button">
        <Border x:Name="Root" CornerRadius="{TemplateBinding ui:ControlHelper.CornerRadius}"
                    Background="{DynamicResource ScrollBarButtonBackground}"
                    BorderBrush="{DynamicResource ScrollBarButtonBorderBrush}"
                    SnapsToDevicePixels="True">
            <ui:FontIcon x:Name="Arrow" HorizontalAlignment="Center" VerticalAlignment="Center"
                             FontFamily="{DynamicResource SymbolThemeFontFamily}"
                             FontSize="10" Glyph="{TemplateBinding Content}"
                             Foreground="{DynamicResource ScrollBarButtonArrowForeground}" />
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="Root" Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPointerOver}" />
                <Setter TargetName="Root" Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushPointerOver}" />
                <Setter TargetName="Arrow" Property="Foreground" Value="{DynamicResource ScrollBarButtonArrowForegroundPointerOver}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="Root" Property="Background" Value="{DynamicResource ScrollBarButtonBackgroundPressed}" />
                <Setter TargetName="Root" Property="BorderBrush" Value="{DynamicResource ScrollBarButtonBorderBrushPressed}" />
                <Setter TargetName="Arrow" Property="Foreground" Value="{DynamicResource ScrollBarButtonArrowForegroundPressed}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="SecondaryContentScrollBarStyleVertical" TargetType="ScrollBar">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="false" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollBar">
                    <Border x:Name="Root" SnapsToDevicePixels="true">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Button x:Name="PART_LineUpButton"
                                        Command="{x:Static ScrollBar.LineUpCommand}"
                                        Height="20" Width="20"
                                        IsTabStop="False"
                                        Margin="4"
                                        Grid.Row="0"
                                        ui:ControlHelper.CornerRadius="6"
                                        Template="{StaticResource SecondaryContentScrollBarButtonTemplate}"
                                        Content="{x:Static utils:CommonGlyphs.ChevronUp}"
                                        HorizontalAlignment="Center">
                                <Button.Visibility>
                                    <MultiBinding Converter="{StaticResource ScrollButtonVisibilityConverter}" ConverterParameter="&gt;">
                                        <Binding RelativeSource="{RelativeSource Mode=TemplatedParent}" Path="Value" />
                                        <Binding RelativeSource="{RelativeSource Mode=TemplatedParent}" Path="Minimum" />
                                    </MultiBinding>
                                </Button.Visibility>
                            </Button>
                            <Button x:Name="PART_LineDownButton"
                                        Command="{x:Static ScrollBar.LineDownCommand}"
                                        Height="20" Width="20"
                                        IsTabStop="False"
                                        Margin="4"
                                        Grid.Row="2"
                                        ui:ControlHelper.CornerRadius="6"
                                        Template="{StaticResource SecondaryContentScrollBarButtonTemplate}"
                                        Content="{x:Static utils:CommonGlyphs.ChevronDown}"
                                        HorizontalAlignment="Center">
                                <Button.Visibility>
                                    <MultiBinding Converter="{StaticResource ScrollButtonVisibilityConverter}" ConverterParameter="&lt;">
                                        <Binding RelativeSource="{RelativeSource Mode=TemplatedParent}" Path="Value" />
                                        <Binding RelativeSource="{RelativeSource Mode=TemplatedParent}" Path="Maximum" />
                                    </MultiBinding>
                                </Button.Visibility>
                            </Button>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="SecondaryContentScrollBarStyleHorizontal" TargetType="ScrollBar">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Orientation" Value="Horizontal" />
        <Setter Property="Stylus.IsPressAndHoldEnabled" Value="false" />
        <Setter Property="Stylus.IsFlicksEnabled" Value="false" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollBar">
                    <Border x:Name="Root" SnapsToDevicePixels="true">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Button x:Name="PART_LineLeftButton"
                                        Command="{x:Static ScrollBar.LineLeftCommand}"
                                        Height="20" Width="20"
                                        IsTabStop="False"
                                        Margin="4"
                                        Grid.Column="0"
                                        ui:ControlHelper.CornerRadius="6"
                                        Template="{StaticResource SecondaryContentScrollBarButtonTemplate}"
                                        Content="{x:Static utils:CommonGlyphs.ChevronLeft}"
                                        VerticalAlignment="Center">
                                <Button.Visibility>
                                    <MultiBinding Converter="{StaticResource ScrollButtonVisibilityConverter}" ConverterParameter="&gt;">
                                        <Binding RelativeSource="{RelativeSource Mode=TemplatedParent}" Path="Value" />
                                        <Binding RelativeSource="{RelativeSource Mode=TemplatedParent}" Path="Minimum" />
                                    </MultiBinding>
                                </Button.Visibility>
                            </Button>
                            <Button x:Name="PART_LineRightButton"
                                        Command="{x:Static ScrollBar.LineRightCommand}"
                                        Height="20" Width="20"
                                        IsTabStop="False"
                                        Margin="4"
                                        Grid.Column="2"
                                        ui:ControlHelper.CornerRadius="6"
                                        Template="{StaticResource SecondaryContentScrollBarButtonTemplate}"
                                        Content="{x:Static utils:CommonGlyphs.ChevronRight}"
                                        VerticalAlignment="Center">
                                <Button.Visibility>
                                    <MultiBinding Converter="{StaticResource ScrollButtonVisibilityConverter}" ConverterParameter="&lt;">
                                        <Binding RelativeSource="{RelativeSource Mode=TemplatedParent}" Path="Value" />
                                        <Binding RelativeSource="{RelativeSource Mode=TemplatedParent}" Path="Maximum" />
                                    </MultiBinding>
                                </Button.Visibility>
                            </Button>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="SecondaryContentScrollViewerStyle" TargetType="ScrollViewer">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
        <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="ui:ControlHelper.CornerRadius" Value="{DynamicResource FlyoutCornerRadius}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollViewer">
                    <Border CornerRadius="{TemplateBinding ui:ControlHelper.CornerRadius}">
                        <Grid Background="{TemplateBinding Background}">
                            <ScrollContentPresenter
                                    x:Name="PART_ScrollContentPresenter"
                                    Margin="{TemplateBinding Padding}"
                                    CanContentScroll="{TemplateBinding CanContentScroll}"
                                    CanHorizontallyScroll="False"
                                    CanVerticallyScroll="False"
                                    Content="{TemplateBinding Content}"
                                    ContentTemplate="{TemplateBinding ContentTemplate}" />
                            <ScrollBar
                                    x:Name="PART_HorizontalScrollBar" Style="{StaticResource SecondaryContentScrollBarStyleHorizontal}"
                                    AutomationProperties.AutomationId="HorizontalScrollBar"
                                    Maximum="{TemplateBinding ScrollableWidth}"
                                    Minimum="0" VerticalAlignment="Top"
                                    Margin="0,0,0,0"
                                    ViewportSize="{TemplateBinding ViewportWidth}"
                                    Orientation="Horizontal"
                                    Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                    Value="{TemplateBinding HorizontalOffset}" />
                            <ScrollBar
                                    x:Name="PART_VerticalScrollBar" Style="{StaticResource SecondaryContentScrollBarStyleVertical}"
                                    AutomationProperties.AutomationId="VerticalScrollBar"
                                    Maximum="{TemplateBinding ScrollableHeight}"
                                    Minimum="0" HorizontalAlignment="Right"
                                    ViewportSize="{TemplateBinding ViewportHeight}"
                                    Orientation="Vertical"
                                    Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                    Value="{TemplateBinding VerticalOffset}" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!--endregion-->
    
</ResourceDictionary>