<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Controls="clr-namespace:MahApps.Metro.Controls">

    <Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="Background" Value="{DynamicResource BackgroundNormal}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrushNormal}" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="1">
                        <Path HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Data="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}"
                              Fill="{DynamicResource Foreground}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{DynamicResource BackgroundHighlighted}" />
                            <Setter Property="BorderBrush" Value="{DynamicResource BorderBrushHighlighted}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Background" Value="{DynamicResource BackgroundSelected}" />
                            <Setter Property="BorderBrush" Value="{DynamicResource BorderBrushSelected}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="{TemplateBinding Background}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{DynamicResource ScrollBarPageButtonBackgroundHighlighted}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="Background" Value="{DynamicResource BackgroundNormal}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BorderBrushNormal}" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="IsTabStop" Value="false" />
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="1" />
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Background" Value="{DynamicResource BackgroundHighlighted}" />
                            <Setter Property="BorderBrush" Value="{DynamicResource BorderBrushHighlighted}" />
                        </Trigger>
                        <Trigger Property="IsDragging" Value="True">
                            <Setter Property="Background" Value="{DynamicResource BackgroundSelected}" />
                            <Setter Property="BorderBrush" Value="{DynamicResource BorderBrushSelected}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="18" />
                <ColumnDefinition />
                <ColumnDefinition Width="18" />
            </Grid.ColumnDefinitions>
            <RepeatButton Grid.Column="0"
                          Command="ScrollBar.LineLeftCommand"
                          Content="M 0 4 L 4 8 L 4 0 Z"
                          Style="{StaticResource ScrollBarLineButton}" />
            <Track Name="PART_Track" Grid.Column="1">
                <Track.DecreaseRepeatButton>
                    <RepeatButton Command="ScrollBar.PageLeftCommand" Style="{StaticResource ScrollBarPageButton}" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Controls:MetroThumb Style="{StaticResource ScrollBarThumb}" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton Command="ScrollBar.PageRightCommand" Style="{StaticResource ScrollBarPageButton}" />
                </Track.IncreaseRepeatButton>
            </Track>
            <RepeatButton Grid.Column="2"
                          Command="ScrollBar.LineRightCommand"
                          Content="M 0 0 L 0 8 L 4 4 Z"
                          Style="{StaticResource ScrollBarLineButton}" />
        </Grid>
    </ControlTemplate>

    <ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="18" />
                <RowDefinition />
                <RowDefinition Height="18" />
            </Grid.RowDefinitions>
            <RepeatButton Grid.Row="0"
                          Command="ScrollBar.LineUpCommand"
                          Content="M 0 4 L 8 4 L 4 0 Z"
                          Style="{StaticResource ScrollBarLineButton}" />
            <Track Name="PART_Track"
                   Grid.Row="1"
                   IsDirectionReversed="true">
                <Track.DecreaseRepeatButton>
                    <RepeatButton Command="ScrollBar.PageUpCommand" Style="{StaticResource ScrollBarPageButton}" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Controls:MetroThumb Style="{StaticResource ScrollBarThumb}" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton Command="ScrollBar.PageDownCommand" Style="{StaticResource ScrollBarPageButton}" />
                </Track.IncreaseRepeatButton>
            </Track>
            <RepeatButton Grid.Row="2"
                          Command="ScrollBar.LineDownCommand"
                          Content="M 0 0 L 4 4 L 8 0 Z"
                          Style="{StaticResource ScrollBarLineButton}" />
        </Grid>
    </ControlTemplate>

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

</ResourceDictionary>