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

    <Style x:Key="VerticalScrollBarThumbStyle" TargetType="{x:Type Thumb}">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="MinHeight" Value="50" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Rectangle
                        Name="ellipse"
                        Width="16"
                        Fill="{StaticResource BackgroundColorBrushFadeSubtle}"
                        Stroke="{StaticResource BorderBrush}" />
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="ellipse" Property="Fill" Value="{DynamicResource ChosenColorBrush}" />
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter TargetName="ellipse" Property="Fill" Value="{DynamicResource ChosenColorBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="HorizontalScrollBarThumbStyle" TargetType="{x:Type Thumb}">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Margin" Value="2,1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Rectangle
                        Name="ellipse"
                        MinWidth="50"
                        Fill="{StaticResource BackgroundColorBrushFadeSubtle}"
                        Stroke="{StaticResource BorderBrush}" />
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="ellipse" Property="Fill" Value="{DynamicResource ChosenColorBrush}" />
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter TargetName="ellipse" Property="Fill" Value="{DynamicResource ChosenColorBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="LineButtonLeftStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid Width="12" Margin="0,3,0,3">
                        <Path
                            Name="Path"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Data="M0.199,10.79l9.646,9.646c0.13,0.133,0.302,0.197,0.471,0.197c0.173,0,0.344-0.064,0.473-0.197l0.013-0.011  C10.929,20.305,11,20.132,11,19.952v-4.68c0-0.182-0.07-0.347-0.198-0.475L6.323,10.32l4.479-4.483C10.929,5.714,11,5.543,11,5.364  V0.682c0-0.176-0.07-0.345-0.198-0.474l-0.013-0.012C10.667,0.071,10.497,0,10.316,0C10.143,0,9.97,0.071,9.845,0.196L0.199,9.845  C-0.066,10.104-0.066,10.532,0.199,10.79z"
                            Fill="{StaticResource IconColorBrush}"
                            Stretch="None" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Path" Property="Fill" Value="{DynamicResource ChosenColorBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Path" Property="Fill" Value="{DynamicResource ChosenColorBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="LineButtonRightStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid Width="12" Margin="0,3,7,3">
                        <Path
                            Name="Path"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            Data="M10.804,9.844L1.154,0.195C1.025,0.064,0.857,0,0.683,0C0.512,0,0.34,0.064,0.21,0.195L0.197,0.207  C0.071,0.334,0,0.506,0,0.682v4.682c0,0.178,0.071,0.348,0.197,0.471l4.481,4.482l-4.481,4.479C0.071,14.922,0,15.09,0,15.271v4.68  c0,0.18,0.071,0.354,0.197,0.475l0.013,0.01c0.124,0.127,0.294,0.197,0.473,0.197s0.348-0.07,0.474-0.197l9.647-9.646  C11.064,10.531,11.064,10.104,10.804,9.844z"
                            Fill="{StaticResource IconColorBrush}"
                            Stretch="None" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Path" Property="Fill" Value="{DynamicResource ChosenColorBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Path" Property="Fill" Value="{DynamicResource ChosenColorBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="LineButtonUpStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid Width="28" Height="30">
                        <Border
                            Name="border"
                            BorderBrush="Transparent"
                            BorderThickness="1">
                            <Path
                                Name="Path"
                                Width="16"
                                Height="16"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Data="F1 M512,512z M0,0z M414,321.94L274.22,158.82A24,24,0,0,0,237.78,158.82L98,321.94C84.66,337.51,95.72,361.56,116.22,361.56L395.82,361.56C416.32,361.56,427.38,337.51,414,321.94z"
                                Fill="#fff"
                                Stretch="Fill" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Path" Property="Fill" Value="{StaticResource ChosenColorBrush}" />
                            <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource ChosenColorBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Path" Property="Fill" Value="{StaticResource ChosenColorBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="LineButtonDownStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Grid Width="28" Height="30">
                        <Border
                            Name="border"
                            BorderBrush="Transparent"
                            BorderThickness="1">
                            <Path
                                Name="Path"
                                Width="18"
                                Height="18"
                                HorizontalAlignment="Center"
                                VerticalAlignment="Center"
                                Data="F1 M512,512z M0,0z M98,190.06L237.78,353.18A24,24,0,0,0,274.22,353.18L414,190.06C427.34,174.49,416.28,150.44,395.78,150.44L116.18,150.44C95.6799999999999,150.44,84.6199999999999,174.49,97.9999999999999,190.06z"
                                Fill="{StaticResource IconColorBrush}"
                                Stretch="Fill" />
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Path" Property="Fill" Value="{StaticResource ChosenColorBrush}" />
                            <Setter TargetName="border" Property="BorderBrush" Value="{StaticResource ChosenColorBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Path" Property="Fill" Value="{StaticResource ChosenColorBrush}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ScrollBarPageButtonStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="Transparent" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
        <Border
            Width="30"
            Background="{StaticResource AltInterfaceBrush}"
            BorderBrush="{StaticResource BorderBrush}"
            BorderThickness="1,0,0,0">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition MaxHeight="30" />
                    <RowDefinition Height="*" />
                    <RowDefinition MaxHeight="30" />
                </Grid.RowDefinitions>
                <RepeatButton
                    Grid.Row="0"
                    Height="30"
                    Command="ScrollBar.LineUpCommand"
                    Style="{StaticResource LineButtonUpStyle}" />

                <Track
                    Name="PART_Track"
                    Grid.Row="1"
                    IsDirectionReversed="True">
                    <Track.DecreaseRepeatButton>
                        <RepeatButton Command="ScrollBar.PageUpCommand" Style="{StaticResource ScrollBarPageButtonStyle}" />
                    </Track.DecreaseRepeatButton>
                    <Track.Thumb>
                        <Thumb Style="{StaticResource VerticalScrollBarThumbStyle}" />
                    </Track.Thumb>
                    <Track.IncreaseRepeatButton>
                        <RepeatButton Command="ScrollBar.PageDownCommand" Style="{StaticResource ScrollBarPageButtonStyle}" />
                    </Track.IncreaseRepeatButton>
                </Track>

                <RepeatButton
                    Grid.Row="2"
                    Height="30"
                    Command="ScrollBar.LineDownCommand"
                    Style="{StaticResource LineButtonDownStyle}" />
            </Grid>
        </Border>
    </ControlTemplate>

    <ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
        <Border
            Background="{StaticResource AltInterfaceBrush}"
            BorderBrush="{StaticResource BorderBrush}"
            BorderThickness="0,1,0,0">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MaxWidth="18" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition MaxWidth="18" />
                </Grid.ColumnDefinitions>
                <RepeatButton
                    Grid.Column="0"
                    Width="25"
                    Command="ScrollBar.LineLeftCommand"
                    Style="{StaticResource LineButtonLeftStyle}" />

                <Track
                    Name="PART_Track"
                    Grid.Column="1"
                    MinWidth="160"
                    IsDirectionReversed="False">
                    <Track.DecreaseRepeatButton>
                        <RepeatButton Command="ScrollBar.PageLeftCommand" Style="{StaticResource ScrollBarPageButtonStyle}" />
                    </Track.DecreaseRepeatButton>
                    <Track.Thumb>
                        <Thumb Style="{StaticResource HorizontalScrollBarThumbStyle}" />
                    </Track.Thumb>
                    <Track.IncreaseRepeatButton>
                        <RepeatButton Command="ScrollBar.PageRightCommand" Style="{StaticResource ScrollBarPageButtonStyle}" />
                    </Track.IncreaseRepeatButton>
                    <Track.Resources>
                        <!--  Thumb's minimum height is half of this metric  -->
                        <system:Double x:Key="{x:Static SystemParameters.HorizontalScrollBarButtonWidthKey}">
                            160
                        </system:Double>
                    </Track.Resources>
                </Track>
                <RepeatButton
                    Grid.Column="2"
                    Width="25"
                    Command="ScrollBar.LineRightCommand"
                    Style="{StaticResource LineButtonRightStyle}" />
            </Grid>
        </Border>
    </ControlTemplate>

    <Style TargetType="{x:Type ScrollBar}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Width" Value="Auto" />
                <Setter Property="Height" Value="Auto" />
                <Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
            </Trigger>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Width" Value="Auto" />
                <Setter Property="Height" Value="20" />
                <Setter Property="Template" Value="{StaticResource HorizontalScrollBar}" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>