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

    <SolidColorBrush x:Key="ScrollBarLineButton_ArrowFill" Color="#868999"/>
    <SolidColorBrush x:Key="ScrollBarLineButton_MouseOverFill" Color="#1C97EA"/>
    <SolidColorBrush x:Key="ScrollBarLineButton_PressedFill" Color="#007ACC"/>

    <SolidColorBrush x:Key="ScrollBarThumb_Background" Color="#C2C3C9"/>
    <SolidColorBrush x:Key="ScrollBarThumb_MouseOverBackground" Color="#686868"/>
    <SolidColorBrush x:Key="ScrollBarThumb_DraggingBackground" Color="#5B5B5B"/>

    <SolidColorBrush x:Key="ScrollBar_Background" Color="#EFEFF2"/>

    <Style x:Key="ScrollBarLineButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Margin="1" CornerRadius="2" BorderThickness="1" Background="{TemplateBinding Background}">
                        <Path x:Name="Arrow" HorizontalAlignment="Center" VerticalAlignment="Center"
                              Fill="{StaticResource ScrollBarLineButton_ArrowFill}"
                              Data="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}"/>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="Arrow" Property="Fill" Value="{StaticResource ScrollBarLineButton_MouseOverFill}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="Arrow" Property="Fill" Value="{StaticResource ScrollBarLineButton_PressedFill}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ScrollBarPageButton" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <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>

    <Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Setter Property="IsTabStop" Value="false" />
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Background" Value="{StaticResource ScrollBarThumb_Background}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border CornerRadius="0" BorderThickness="1" 
                            Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="{StaticResource ScrollBarThumb_MouseOverBackground}"/>
            </Trigger>
            <Trigger Property="IsDragging" Value="true">
                <Setter Property="Background" Value="{StaticResource ScrollBarThumb_DraggingBackground}"/>
            </Trigger>
        </Style.Triggers>
    </Style>

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

    <ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
        <Grid Background="{TemplateBinding Background}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition MaxWidth="15" />
                <ColumnDefinition Width="0.00001*" />
                <ColumnDefinition MaxWidth="15" />
            </Grid.ColumnDefinitions>
            <RepeatButton Grid.Column="0" Content="M 4 0 L 4 8 L 0 4 Z"
                          Style="{StaticResource ScrollBarLineButton}" Command="ScrollBar.LineLeftCommand"/>
            <Track x:Name="PART_Track" Grid.Column="1" IsDirectionReversed="False">
                <Track.DecreaseRepeatButton>
                    <RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageLeftCommand" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb Style="{StaticResource ScrollBarThumb}" Margin="0,2"/>
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageRightCommand" />
                </Track.IncreaseRepeatButton>
            </Track>
            <RepeatButton Grid.Column="2" Content="M 0 0 L 4 4 L 0 8 Z"
                          Style="{StaticResource ScrollBarLineButton}" Command="ScrollBar.LineRightCommand"/>
        </Grid>
    </ControlTemplate>

    <Style x:Key="{x:Static themes:ResourceKeys.NormalScrollBarStyleKey}"  TargetType="{x:Type ScrollBar}">
        <Setter Property="Background" Value="{StaticResource ScrollBar_Background}"/>
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="OverridesDefaultStyle" Value="true" />
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Width" Value="Auto" />
                <Setter Property="Height" Value="16" />
                <Setter Property="Template" Value="{StaticResource HorizontalScrollBar}" />
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Width" Value="16" />
                <Setter Property="Height" Value="Auto" />
                <Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="{x:Static themes:ResourceKeys.NormalScrollViewerStyleKey}" 
           TargetType="{x:Type ScrollViewer}">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        <ScrollContentPresenter CanHorizontallyScroll="False" 
                                                CanVerticallyScroll="False" 
                                                CanContentScroll="{TemplateBinding CanContentScroll}" 
                                                ContentTemplate="{TemplateBinding ContentTemplate}" 
                                                Content="{TemplateBinding Content}" 
                                                Margin="{TemplateBinding Padding}"/>
                        <ScrollBar x:Name="PART_VerticalScrollBar"
                                   Grid.Row="0" Grid.Column="1"
                                   Value="{TemplateBinding VerticalOffset}"
                                   Maximum="{TemplateBinding ScrollableHeight}"
                                   ViewportSize="{TemplateBinding ViewportHeight}"
                                   Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                   Style="{StaticResource {x:Static themes:ResourceKeys.NormalScrollBarStyleKey}}"/>
                        <ScrollBar x:Name="PART_HorizontalScrollBar" 
                                   Orientation="Horizontal" Grid.Row="1" Grid.Column="0"
                                   Value="{TemplateBinding HorizontalOffset}"
                                   Maximum="{TemplateBinding ScrollableWidth}"
                                   ViewportSize="{TemplateBinding ViewportWidth}"
                                   Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                   Style="{StaticResource {x:Static themes:ResourceKeys.NormalScrollBarStyleKey}}"/>
                        <Rectangle Grid.Row="1" Grid.Column="1" Fill="{StaticResource ScrollBar_Background}"/>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>