<ResourceDictionary xmlns="https://github.com/avaloniaui"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <ControlTheme x:Key="{x:Type ScrollBar}"
                TargetType="ScrollBar">
    <Setter Property="Cursor" Value="Arrow" />

    <Style Selector="^:horizontal">
      <Setter Property="Height" Value="{DynamicResource ScrollBarThickness}" />
      <Setter Property="Template">
        <ControlTemplate>
          <Border Background="{DynamicResource ThemeControlMidBrush}"
                  UseLayoutRounding="False">
            <Grid ColumnDefinitions="Auto,*,Auto">
              <RepeatButton Name="PART_LineUpButton"
                            Grid.Row="0"
                            Grid.Column="0"
                            MinWidth="{DynamicResource ScrollBarThickness}"
                            VerticalAlignment="Center"
                            Classes="repeat"
                            Focusable="False">
                <Path Data="M 4 0 L 4 8 L 0 4 Z" />
              </RepeatButton>
              <Track Grid.Row="1"
                     Grid.Column="1"
                     Maximum="{TemplateBinding Maximum}"
                     Minimum="{TemplateBinding Minimum}"
                     Orientation="{TemplateBinding Orientation}"
                     ViewportSize="{TemplateBinding ViewportSize}"
                     Value="{TemplateBinding Value,
                                             Mode=TwoWay}">
                <Track.DecreaseButton>
                  <RepeatButton Name="PART_PageUpButton"
                                Classes="repeattrack"
                                Focusable="False" />
                </Track.DecreaseButton>
                <Track.IncreaseButton>
                  <RepeatButton Name="PART_PageDownButton"
                                Classes="repeattrack"
                                Focusable="False" />
                </Track.IncreaseButton>
                  <Thumb Name="thumb"
                         CornerRadius="{DynamicResource ControlCornerRadius}"
                         Background="{DynamicResource ThemeControlHighBrush}"/>

              </Track>
              <RepeatButton Name="PART_LineDownButton"
                            Grid.Row="2"
                            Grid.Column="2"
                            MinWidth="{DynamicResource ScrollBarThickness}"
                            VerticalAlignment="Center"
                            Classes="repeat"
                            Focusable="False">
                <Path Data="M 0 0 L 4 4 L 0 8 Z" />
              </RepeatButton>
            </Grid>
          </Border>
        </ControlTemplate>
      </Setter>
    </Style>
    <Style Selector="^:vertical">
      <Setter Property="Width" Value="{DynamicResource ScrollBarThickness}" />
      <Setter Property="Template">
        <ControlTemplate>
          <Border Background="{DynamicResource ThemeControlMidBrush}"
                  UseLayoutRounding="False">
            <Grid RowDefinitions="Auto,*,Auto">
              <RepeatButton Name="PART_LineUpButton"
                            Grid.Row="0"
                            MinHeight="{DynamicResource ScrollBarThickness}"
                            HorizontalAlignment="Center"
                            Classes="repeat"
                            Focusable="False">
                <Path Data="M 0 4 L 8 4 L 4 0 Z" />
              </RepeatButton>
              <Track Grid.Row="1"
                     Grid.Column="1"
                     IsDirectionReversed="True"
                     Maximum="{TemplateBinding Maximum}"
                     Minimum="{TemplateBinding Minimum}"
                     Orientation="{TemplateBinding Orientation}"
                     ViewportSize="{TemplateBinding ViewportSize}"
                     Value="{TemplateBinding Value,
                                             Mode=TwoWay}">
                <Track.DecreaseButton>
                  <RepeatButton Name="PART_PageUpButton"
                                Classes="repeattrack"
                                Focusable="False" />
                </Track.DecreaseButton>
                <Track.IncreaseButton>
                  <RepeatButton Name="PART_PageDownButton"
                                Classes="repeattrack"
                                Focusable="False" />
                </Track.IncreaseButton>
                <Thumb Name="thumb"
                       CornerRadius="{DynamicResource ControlCornerRadius}"
                       Background="{DynamicResource ThemeControlHighBrush}"/>
              </Track>
              <RepeatButton Name="PART_LineDownButton"
                            Grid.Row="2"
                            Grid.Column="2"
                            MinHeight="{DynamicResource ScrollBarThickness}"
                            HorizontalAlignment="Center"
                            Classes="repeat"
                            Focusable="False">
                <Path Data="M 0 0 L 4 4 L 8 0 Z" />
              </RepeatButton>
            </Grid>
          </Border>
        </ControlTemplate>
      </Setter>
    </Style>
    <Style Selector="^ /template/ Thumb#thumb">
      <Setter Property="Background" Value="{DynamicResource ThemeControlMidHighBrush}" />
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate>
            <Border Background="{TemplateBinding Background}"
                    CornerRadius="{TemplateBinding CornerRadius}" />
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
    <Style Selector="^ /template/ Thumb#thumb:pointerover">
      <Setter Property="Background" Value="{DynamicResource ThemeControlHighlightBrush}" />
    </Style>
    <Style Selector="^ /template/ Thumb#thumb:pressed">
      <Setter Property="Background" Value="{DynamicResource ThemeControlHighlightBrush}" />
    </Style>
    <Style Selector="^:horizontal /template/ Thumb#thumb">
      <Setter Property="MinWidth" Value="{DynamicResource ScrollBarThickness}" />
      <Setter Property="Height" Value="{DynamicResource ScrollBarThumbThickness}" />
    </Style>
    <Style Selector="^:vertical /template/ Thumb#thumb">
      <Setter Property="MinHeight" Value="{DynamicResource ScrollBarThickness}" />
      <Setter Property="Width" Value="{DynamicResource ScrollBarThumbThickness}" />
    </Style>
    <Style Selector="^ /template/ RepeatButton.repeat">
      <Setter Property="Padding" Value="2" />
      <Setter Property="BorderThickness" Value="0" />
    </Style>
    <Style Selector="^ /template/ RepeatButton.repeattrack">
      <Setter Property="Template">
        <ControlTemplate>
          <Border Background="{TemplateBinding Background}" />
        </ControlTemplate>
      </Setter>
    </Style>

    <Style Selector="^ /template/ RepeatButton > Path">
      <Setter Property="Fill" Value="{DynamicResource ThemeForegroundBrush}" />
      <Setter Property="Opacity" Value="0.5"/>
    </Style>

    <Style Selector="^ /template/ RepeatButton:pointerover > Path">
        <Setter Property="Opacity" Value="1"/>
    </Style>
  </ControlTheme>
</ResourceDictionary>