<!-- **************************************************************************

  Copyright (c) 2010 CubeSoft, Inc.

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published
  by the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.

*************************************************************************** -->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!-- **********************************************************************
      ScrollBarTrack
    *********************************************************************** -->
    <ControlTemplate x:Key="ScrollBarTrackTemplate" TargetType="{x:Type RepeatButton}">
        <Border Background="Transparent" />
    </ControlTemplate>

    <!-- **********************************************************************
      ScrollBarThumb
    *********************************************************************** -->
    <ControlTemplate x:Key="ScrollBarThumbTemplate" TargetType="{x:Type Thumb}">
        <Border
            x:Name="ScrollBarThumbButton"
            Background="{StaticResource ScrollBarBrush}"
            BorderThickness="0"
            CornerRadius="4" />
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter
                    TargetName="ScrollBarThumbButton"
                    Property="Background"
                    Value="{StaticResource ScrollBarHoverBrush}" />
            </Trigger>
            <Trigger Property="IsDragging" Value="True">
                <Setter
                    TargetName="ScrollBarThumbButton"
                    Property="Background"
                    Value="{StaticResource ScrollBarDragBrush}" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- **********************************************************************
      VerticalScrollBar
    *********************************************************************** -->
    <ControlTemplate x:Key="VerticalScrollBarTemplate" TargetType="{x:Type ScrollBar}">
        <Track x:Name="PART_Track" IsDirectionReversed="true">
            <Track.DecreaseRepeatButton>
                <RepeatButton
                    Command="ScrollBar.PageUpCommand"
                    Template="{StaticResource ScrollBarTrackTemplate}" />
            </Track.DecreaseRepeatButton>
            <Track.Thumb>
                <Thumb Template="{StaticResource ScrollBarThumbTemplate}" />
            </Track.Thumb>
            <Track.IncreaseRepeatButton>
                <RepeatButton
                    Command="ScrollBar.PageDownCommand"
                    Template="{StaticResource ScrollBarTrackTemplate}" />
            </Track.IncreaseRepeatButton>
        </Track>
    </ControlTemplate>

    <!-- **********************************************************************
      ScrollBar
    *********************************************************************** -->
    <Style x:Key="ScrollBarStyle" TargetType="{x:Type ScrollBar}">
        <Setter Property="OverridesDefaultStyle" Value="True" />
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Width" Value="8" />
                <Setter Property="Height" Value="Auto" />
                <Setter Property="Margin" Value="0,3,6,3" />
                <Setter Property="Template" Value="{StaticResource VerticalScrollBarTemplate}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- **********************************************************************
      ScrollViewer
    *********************************************************************** -->
    <ControlTemplate x:Key="ScrollViewerTemplate" TargetType="{x:Type ScrollViewer}">
        <Grid Background="{TemplateBinding Background}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>

            <ScrollContentPresenter />
            <ScrollBar
                x:Name="PART_VerticalScrollBar"
                Orientation="Vertical"
                Value="{TemplateBinding VerticalOffset}"
                Maximum="{TemplateBinding ScrollableHeight}"
                ViewportSize="{TemplateBinding ViewportHeight}"
                Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
                Style="{StaticResource ScrollBarStyle}"
                Grid.Column="1" />
        </Grid>
    </ControlTemplate>
</ResourceDictionary>