<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
    xmlns:s="clr-namespace:System;assembly=mscorlib">

    <!--
        Everything here is for the scrollbar
        Edit or replace it with with any style for the scrollbar, select the third scrollbar option in Settings, and restart the program
        (keep the copy in case of invalid style)
    -->
    <Style x:Key="ScrollBarTrackThumb" TargetType="{x:Type Thumb}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Grid x:Name="Grid">
                        <Rectangle
                            Width="Auto"
                            Height="Auto"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            Fill="Transparent" />
                        <Border
                            x:Name="CornerScrollBarRectangle"
                            Width="Auto"
                            Height="Auto"
                            Margin="3,0,3,0"
                            HorizontalAlignment="Stretch"
                            VerticalAlignment="Stretch"
                            Background="{TemplateBinding Background}"
                            CornerRadius="2" />
                        <!--  scrollbar THUMB color  -->
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="Tag" Value="Horizontal">
                            <Setter TargetName="CornerScrollBarRectangle" Property="Width" Value="Auto" />
                            <Setter TargetName="CornerScrollBarRectangle" Property="Height" Value="6" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type ScrollBar}">
        <Setter Property="Stylus.IsFlicksEnabled" Value="false" />
        <Setter Property="Foreground" Value="#aaaaaa" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Width" Value="12" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollBar}">
                    <Grid x:Name="GridRoot">
                        <!--  Background="{DynamicResource ScrollBarTrackBrush}" Width="12" HorizontalAlignment="Center"  -->
                        <!--  scrollbar track color  -->
                        <Grid.RowDefinitions>
                            <RowDefinition Height="0.00001*" />
                        </Grid.RowDefinitions>
                        <Border
                            Margin="1,0,1,0"
                            Background="{DynamicResource ScrollBarTrackBrush}"
                            CornerRadius="3" />
                        <Track
                            x:Name="PART_Track"
                            Grid.Row="0"
                            Margin="0,2,0,2"
                            Focusable="false"
                            IsDirectionReversed="true">
                            <Track.Thumb>
                                <Thumb
                                    x:Name="Thumb"
                                    Background="{DynamicResource ScrollBarThumbBrush}"
                                    Style="{DynamicResource ScrollBarTrackThumb}" />
                            </Track.Thumb>
                            <Track.IncreaseRepeatButton>
                                <RepeatButton
                                    x:Name="PageUp"
                                    VerticalAlignment="Stretch"
                                    Command="ScrollBar.PageDownCommand"
                                    Focusable="false"
                                    Opacity="0" />
                            </Track.IncreaseRepeatButton>
                            <Track.DecreaseRepeatButton>
                                <RepeatButton
                                    x:Name="PageDown"
                                    VerticalAlignment="Stretch"
                                    Command="ScrollBar.PageUpCommand"
                                    Focusable="false"
                                    Opacity="0" />
                            </Track.DecreaseRepeatButton>
                        </Track>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger SourceName="Thumb" Property="IsMouseOver" Value="true">
                            <Setter TargetName="Thumb" Property="Background" Value="{DynamicResource ScrollBarThumbHoverBrush}" />
                        </Trigger>
                        <Trigger SourceName="Thumb" Property="IsDragging" Value="true">
                            <Setter TargetName="Thumb" Property="Background" Value="{DynamicResource ScrollBarThumbHoverBrush}" />
                        </Trigger>

                        <Trigger Property="IsEnabled" Value="false">
                            <Setter TargetName="Thumb" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="Orientation" Value="Vertical">
                            <Setter Property="Width" Value="12" />
                            <Setter Property="MinWidth" Value="12" />

                        </Trigger>

                        <Trigger Property="Orientation" Value="Horizontal">
                            <Setter TargetName="GridRoot" Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="-90" />
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="PART_Track" Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="-90" />
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Width" Value="Auto" />
                            <Setter Property="Height" Value="12" />
                            <Setter Property="MinHeight" Value="12" />
                            <Setter TargetName="Thumb" Property="Tag" Value="Horizontal" />
                            <Setter TargetName="PageDown" Property="Command" Value="ScrollBar.PageLeftCommand" />
                            <Setter TargetName="PageUp" Property="Command" Value="ScrollBar.PageRightCommand" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!--  Background Transparent (or other color is required) because without this the scrollbar repeater (space under/over thumb) wont work for scroll to next/previous page)  -->
    <Style TargetType="RepeatButton">
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="IsTabStop" Value="false" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="RepeatButton">
                    <Rectangle
                        Width="{TemplateBinding Width}"
                        Height="{TemplateBinding Height}"
                        Fill="{TemplateBinding Background}"
                        SnapsToDevicePixels="True" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>