<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:primitives="clr-namespace:ModernWpf.Controls.Primitives">

    <Duration x:Key="ScrollViewerSeparatorExpandDuration">00:00:00.1</Duration>
    <KeyTime x:Key="ScrollViewerSeparatorContractDelay">00:00:02</KeyTime>
    <Duration x:Key="ScrollViewerSeparatorContractDuration">00:00:00.1</Duration>
    <KeyTime x:Key="ScrollViewerSeparatorContractKeyTime">00:00:00.1</KeyTime>
    <KeyTime x:Key="ScrollViewerSeparatorContractFinalKeyframe">00:00:02.1</KeyTime>

    <Style x:Key="DefaultScrollViewerStyle" TargetType="ScrollViewer">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
        <Setter Property="VerticalScrollBarVisibility" Value="Visible" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="FocusVisualStyle" Value="{DynamicResource {x:Static SystemParameters.FocusVisualStyleKey}}" />
        <Setter Property="primitives:FocusVisualHelper.UseSystemFocusVisuals" Value="{DynamicResource UseSystemFocusVisuals}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollViewer">
                    <Border
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}">
                        <Grid Background="{TemplateBinding Background}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <ScrollContentPresenter
                                x:Name="PART_ScrollContentPresenter"
                                Grid.Row="0"
                                Grid.Column="0"
                                Grid.RowSpan="2"
                                Grid.ColumnSpan="2"
                                Margin="{TemplateBinding Padding}"
                                CanContentScroll="{TemplateBinding CanContentScroll}"
                                CanHorizontallyScroll="False"
                                CanVerticallyScroll="False"
                                Content="{TemplateBinding Content}"
                                ContentTemplate="{TemplateBinding ContentTemplate}" />
                            <ScrollBar
                                x:Name="PART_VerticalScrollBar"
                                Grid.Row="0"
                                Grid.Column="1"
                                AutomationProperties.AutomationId="VerticalScrollBar"
                                Maximum="{TemplateBinding ScrollableHeight}"
                                Minimum="0"
                                ViewportSize="{TemplateBinding ViewportHeight}"
                                Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                Value="{TemplateBinding VerticalOffset}" />
                            <ScrollBar
                                x:Name="PART_HorizontalScrollBar"
                                Grid.Row="1"
                                Grid.Column="0"
                                AutomationProperties.AutomationId="HorizontalScrollBar"
                                Maximum="{TemplateBinding ScrollableWidth}"
                                Minimum="0"
                                Orientation="Horizontal"
                                ViewportSize="{TemplateBinding ViewportWidth}"
                                Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                Value="{TemplateBinding HorizontalOffset}" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="ScrollViewer" BasedOn="{StaticResource DefaultScrollViewerStyle}" />

    <Style x:Key="TextControlContentHostStyle" TargetType="ScrollViewer" BasedOn="{StaticResource DefaultScrollViewerStyle}">
        <Setter Property="primitives:TextControlContentHostHelper.ContentPresenterMargin" Value="-2,0" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ScrollViewer">
                    <Border
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        CornerRadius="{TemplateBinding primitives:ControlHelper.CornerRadius}">
                        <Grid Background="{TemplateBinding Background}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Border
                                Grid.Row="0"
                                Grid.Column="0"
                                Grid.RowSpan="2"
                                Grid.ColumnSpan="2"
                                Padding="{TemplateBinding Padding}">
                                <ScrollContentPresenter
                                    x:Name="PART_ScrollContentPresenter"
                                    Margin="{TemplateBinding primitives:TextControlContentHostHelper.ContentPresenterMargin}"
                                    CanContentScroll="{TemplateBinding CanContentScroll}"
                                    CanHorizontallyScroll="False"
                                    CanVerticallyScroll="False"
                                    Content="{TemplateBinding Content}"
                                    ContentTemplate="{TemplateBinding ContentTemplate}" />
                            </Border>
                            <ScrollBar
                                x:Name="PART_VerticalScrollBar"
                                Grid.Row="0"
                                Grid.Column="1"
                                AutomationProperties.AutomationId="VerticalScrollBar"
                                Maximum="{TemplateBinding ScrollableHeight}"
                                Minimum="0"
                                ViewportSize="{TemplateBinding ViewportHeight}"
                                Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                                Value="{TemplateBinding VerticalOffset}" />
                            <ScrollBar
                                x:Name="PART_HorizontalScrollBar"
                                Grid.Row="1"
                                Grid.Column="0"
                                AutomationProperties.AutomationId="HorizontalScrollBar"
                                Maximum="{TemplateBinding ScrollableWidth}"
                                Minimum="0"
                                Orientation="Horizontal"
                                ViewportSize="{TemplateBinding ViewportWidth}"
                                Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
                                Value="{TemplateBinding HorizontalOffset}" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <ControlTemplate TargetType="ScrollViewer" x:Key="ScrollViewerScrollBarlessTemplate">
        <Grid Background="{TemplateBinding Background}">
            <ScrollContentPresenter
                x:Name="ScrollContentPresenter"
                ContentTemplate="{TemplateBinding ContentTemplate}"
                Margin="{TemplateBinding Padding}" />
        </Grid>
    </ControlTemplate>

</ResourceDictionary>