<ResourceDictionary
    x:ClassModifier="internal"
    xmlns="https://github.com/avaloniaui"
    xmlns:converters="using:Avalonia.Controls.Converters"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <ControlTheme TargetType="ScrollViewer" x:Key="{x:Type ScrollViewer}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <ControlTemplate>
                <Grid ColumnDefinitions="*,Auto" RowDefinitions="*,Auto">
                    <ScrollContentPresenter
                        Background="{TemplateBinding Background}"
                        HorizontalSnapPointsAlignment="{TemplateBinding HorizontalSnapPointsAlignment}"
                        HorizontalSnapPointsType="{TemplateBinding HorizontalSnapPointsType}"
                        Name="PART_ContentPresenter"
                        Padding="{TemplateBinding Padding}"
                        ScrollViewer.IsScrollInertiaEnabled="{TemplateBinding IsScrollInertiaEnabled}"
                        VerticalSnapPointsAlignment="{TemplateBinding VerticalSnapPointsAlignment}"
                        VerticalSnapPointsType="{TemplateBinding VerticalSnapPointsType}">
                        <ScrollContentPresenter.GestureRecognizers>
                            <ScrollGestureRecognizer
                                CanHorizontallyScroll="{Binding CanHorizontallyScroll, ElementName=PART_ContentPresenter}"
                                CanVerticallyScroll="{Binding CanVerticallyScroll, ElementName=PART_ContentPresenter}"
                                IsScrollInertiaEnabled="{Binding (ScrollViewer.IsScrollInertiaEnabled), ElementName=PART_ContentPresenter}" />
                        </ScrollContentPresenter.GestureRecognizers>
                    </ScrollContentPresenter>
                    <ScrollBar
                        Grid.Row="1"
                        Name="PART_HorizontalScrollBar"
                        Orientation="Horizontal" />
                    <ScrollBar
                        Grid.Column="1"
                        Name="PART_VerticalScrollBar"
                        Orientation="Vertical" />
                    <Panel
                        Background="{DynamicResource MainBackgroundColor}"
                        Grid.Column="1"
                        Grid.Row="1" />
                </Grid>
            </ControlTemplate>
        </Setter>
    </ControlTheme>

    <ControlTheme TargetType="ScrollViewer" x:Key="SimpleMenuScrollViewer">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <ControlTemplate>
                <DockPanel>
                    <RepeatButton
                        Background="Transparent"
                        BorderThickness="0"
                        Command="{Binding LineUp, RelativeSource={RelativeSource TemplatedParent}}"
                        DockPanel.Dock="Top">
                        <RepeatButton.IsVisible>
                            <MultiBinding Converter="{x:Static converters:MenuScrollingVisibilityConverter.Instance}"
                                          ConverterParameter="0">
                                <Binding Path="VerticalScrollBarVisibility"
                                         RelativeSource="{RelativeSource TemplatedParent}" />
                                <Binding Path="Offset.Y" RelativeSource="{RelativeSource TemplatedParent}" />
                                <Binding Path="Extent.Height" RelativeSource="{RelativeSource TemplatedParent}" />
                                <Binding Path="Viewport.Height" RelativeSource="{RelativeSource TemplatedParent}" />
                            </MultiBinding>
                        </RepeatButton.IsVisible>
                        <Path Data="M 0 4 L 8 4 L 4 0 Z" />
                    </RepeatButton>
                    <RepeatButton
                        Background="Transparent"
                        BorderThickness="0"
                        Command="{Binding LineDown, RelativeSource={RelativeSource TemplatedParent}}"
                        DockPanel.Dock="Bottom">
                        <RepeatButton.IsVisible>
                            <MultiBinding Converter="{x:Static converters:MenuScrollingVisibilityConverter.Instance}"
                                          ConverterParameter="100">
                                <Binding Path="VerticalScrollBarVisibility"
                                         RelativeSource="{RelativeSource TemplatedParent}" />
                                <Binding Path="Offset.Y" RelativeSource="{RelativeSource TemplatedParent}" />
                                <Binding Path="Extent.Height" RelativeSource="{RelativeSource TemplatedParent}" />
                                <Binding Path="Viewport.Height" RelativeSource="{RelativeSource TemplatedParent}" />
                            </MultiBinding>
                        </RepeatButton.IsVisible>
                        <Path Data="M 0 0 L 4 4 L 8 0 Z" />
                    </RepeatButton>
                    <ScrollContentPresenter Margin="{TemplateBinding Padding}" Name="PART_ContentPresenter" />
                </DockPanel>
            </ControlTemplate>
        </Setter>
        <Style Selector="^ /template/ RepeatButton &gt; Path">
            <Setter Property="Fill" Value="{DynamicResource MainBackgroundColor}" />
        </Style>

        <Style Selector="^ /template/ RepeatButton:pointerover &gt; Path">
            <Setter Property="Fill" Value="{DynamicResource AccentColor}" />
        </Style>
    </ControlTheme>
</ResourceDictionary>