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

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Base/ScrollViewerBaseStyle.xaml"/>
        <ResourceDictionary Source="../Basic/Converters.xaml"/>
        <ResourceDictionary Source="../Basic/Geometries.xaml"/>
        <ResourceDictionary Source="RepeatButton.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <!--default style-->
    <Style BasedOn="{StaticResource ScrollViewerNativeBaseStyle}" TargetType="ScrollViewer"/>

    <Style BasedOn="{StaticResource ScrollViewerBaseStyle}" TargetType="controls:ScrollViewer"/>

    <Style x:Key="ScrollViewerUpDownRepeatButtonStyle" BasedOn="{StaticResource RepeatButtonIcon}" TargetType="RepeatButton">
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="Height" Value="10"/>
        <Setter Property="Padding" Value="0,2"/>
        <Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
        <Setter Property="Visibility">
            <Setter.Value>
                <MultiBinding FallbackValue="Visibility.Collapsed" Converter="{StaticResource MenuScrollingVisibilityConverter}" ConverterParameter="0">
                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ComputedVerticalScrollBarVisibility" />
                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="VerticalOffset" />
                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ExtentHeight" />
                    <Binding RelativeSource="{RelativeSource TemplatedParent}" Path="ViewportHeight" />
                </MultiBinding>
            </Setter.Value>
        </Setter>
    </Style>
    
    <ControlTemplate x:Key="ScrollViewerUpDownControlTemplate" TargetType="ScrollViewer">
        <Grid x:Name="Grid" Background="{TemplateBinding Background}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <RepeatButton Style="{StaticResource ScrollViewerUpDownRepeatButtonStyle}" controls:IconElement.Geometry="{StaticResource UpGeometry}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Command="{x:Static ScrollBar.LineUpCommand}"/>
            <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" CanHorizontallyScroll="False" CanVerticallyScroll="False" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Margin="{TemplateBinding Padding}" Grid.Row="1"/>
            <RepeatButton Style="{StaticResource ScrollViewerUpDownRepeatButtonStyle}" controls:IconElement.Geometry="{StaticResource DownGeometry}" CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" Grid.Row="2" Command="{x:Static ScrollBar.LineDownCommand}"/>
        </Grid>
    </ControlTemplate>
    
    <Style x:Key="ScrollViewerUpDown" TargetType="ScrollViewer">
        <Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
        <Setter Property="Focusable" Value="False"/>
        <Setter Property="Template" Value="{StaticResource ScrollViewerUpDownControlTemplate}"/>
    </Style>

</ResourceDictionary>