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

   Extended WPF Toolkit

   Copyright (C) 2007-2013 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license 

   For more features, controls, and fast professional support,
   pick up the Plus Edition at http://xceed.com/wpf_toolkit

   Stay informed: follow @datagrid on Twitter or Like http://facebook.com/datagrids

  **********************************************************************************-->

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:sys="clr-namespace:System;assembly=mscorlib"
                    xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes"
                    xmlns:local="clr-namespace:Xceed.Wpf.Toolkit"
                    xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Converters"
                    xmlns:coreConv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters">

   <coreConv:SolidColorBrushToColorConverter x:Key="SolidColorBrushToColorConverter" />

    <!-- //#TODODOC
         Repeat Button - This is used by RangeSlider for the LowerRange, Range, and HigherRange buttons -->
   <Style x:Key="DefaultRangeStyle"
          TargetType="{x:Type RepeatButton}">
      <Setter Property="Focusable"
              Value="False" />
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type RepeatButton}">
               <Grid>
                  <Rectangle x:Name="MainBorder"
                             Fill="{TemplateBinding Background}" />
               </Grid>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!--//##TODODOC-->
   <!--Since a thumb is pretty small, we put a bigger visual clue
   outside the thumb bounds to give the user a hint where the focus is-->
   <Style x:Key="ThumbFocusVisualStyle">
      <Setter Property="Control.Template">
         <Setter.Value>
            <ControlTemplate>
               <Rectangle Margin="-2"
                          StrokeThickness="1"
                          Stroke="Black"
                          StrokeDashArray="1 2" />
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <!-- ********************** -->
    <!-- Thumb Template    -->
    <!-- ********************** -->
   <ControlTemplate x:Key="ThumbTemplate"
                    TargetType="{x:Type Thumb}">
      <Grid>
         <Rectangle x:Name="BackgroundFadingRect"
                    Fill="Black"
                    Width="11"
                    Height="20"
                    SnapsToDevicePixels="True" />
         <Rectangle x:Name="MainBorder"
                    Fill="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background, TargetNullValue=#FFF0F0F0}"
                    StrokeThickness="1"
                    Stroke="#FFACACAC"
                    Opacity="1"
                    Width="11"
                    Height="20"
                    SnapsToDevicePixels="True" />
      </Grid>
      <ControlTemplate.Triggers>
         <DataTrigger Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background, Converter={StaticResource SolidColorBrushToColorConverter}}"
                      Value="Transparent">
            <Setter Property="Visibility"
                    TargetName="BackgroundFadingRect"
                    Value="Collapsed" />
         </DataTrigger>
         <Trigger Property="IsMouseOver"
                  Value="True">
            <Setter Property="Opacity"
                    TargetName="MainBorder"
                    Value="0.75" />
         </Trigger>
         <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
               <Condition Binding="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Background}"
                          Value="{x:Null}" />
               <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}"
                          Value="True" />
            </MultiDataTrigger.Conditions>
            <Setter Property="Opacity"
                    TargetName="MainBorder"
                    Value="1" />
            <Setter Property="Stroke"
                    TargetName="MainBorder"
                    Value="#FF7EB4EA" />
            <Setter Property="Fill"
                    TargetName="MainBorder"
                    Value="#FFDCECFC" />
         </MultiDataTrigger>

         <Trigger Property="IsEnabled"
                  Value="False">
            <Setter Property="Opacity"
                    TargetName="MainBorder"
                    Value="1" />
            <Setter Property="Stroke"
                    TargetName="MainBorder"
                    Value="#FFD9D9D9" />
            <Setter Property="Fill"
                    TargetName="MainBorder"
                    Value="#FFF0F0F0" />
         </Trigger>
         <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Slider}}, Path=Orientation}"
                      Value="Vertical">
            <Setter TargetName="MainBorder"
                    Property="Width"
                    Value="20" />
            <Setter TargetName="MainBorder"
                    Property="Height"
                    Value="11" />
            <Setter TargetName="BackgroundFadingRect"
                    Property="Width"
                    Value="20" />
            <Setter TargetName="BackgroundFadingRect"
                    Property="Height"
                    Value="11" />
         </DataTrigger>
      </ControlTemplate.Triggers>
   </ControlTemplate>

   <!-- ********************** -->
   <!-- Slider Template     -->
   <!-- ********************** -->
   <ControlTemplate x:Key="SliderTemplate"
                    TargetType="{x:Type Slider}">
      <Border SnapsToDevicePixels="True"
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}">
         <Track x:Name="PART_Track"
                  Orientation="{TemplateBinding Orientation}">
            <Track.Thumb>
               <Thumb x:Name="Thumb"
                        Focusable="True"
                        FocusVisualStyle="{StaticResource ThumbFocusVisualStyle}"
                        Background="{TemplateBinding Background}"
                        Template="{StaticResource ThumbTemplate}">
               </Thumb>
            </Track.Thumb>
         </Track>
      </Border>
   </ControlTemplate>

   <!-- ********************** -->
   <!-- HorizontalTickSlider Template     -->
   <!-- ********************** -->
   <ControlTemplate x:Key="HorizontalTickSliderTemplate"
                    TargetType="{x:Type Slider}">
      <Grid>
         <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
         </Grid.RowDefinitions>

         <TickBar Name="TopTick"
                  Grid.Row="0"
                  SnapsToDevicePixels="True"
                  Placement="Top"
                  Fill="Black"
                  Height="4"
                  Visibility="Collapsed" />

         <Border Grid.Row="1"
                 SnapsToDevicePixels="true"
                 Visibility="Hidden">
            <Track x:Name="PART_Track"
                   Orientation="{TemplateBinding Orientation}">
               <Track.Thumb>
                  <Thumb x:Name="Thumb"
                         Focusable="True"
                         Template="{StaticResource ThumbTemplate}">
                  </Thumb>
               </Track.Thumb>
            </Track>
         </Border>

         <TickBar Name="BottomTick"
                  Grid.Row="2"
                  SnapsToDevicePixels="True"
                  Fill="Black"
                  Placement="Bottom"
                  Height="4"
                  Visibility="Collapsed" />
      </Grid>

      <ControlTemplate.Triggers>
         <DataTrigger Binding="{Binding TickPlacement, RelativeSource={RelativeSource AncestorType={x:Type local:RangeSlider}}}"
                      Value="TopLeft">
            <Setter TargetName="TopTick"
                    Property="Visibility"
                    Value="Visible" />
         </DataTrigger>
         <DataTrigger Binding="{Binding TickPlacement, RelativeSource={RelativeSource AncestorType={x:Type local:RangeSlider}}}"
                      Value="BottomRight">
            <Setter TargetName="BottomTick"
                    Property="Visibility"
                    Value="Visible" />
         </DataTrigger>
         <DataTrigger Binding="{Binding TickPlacement, RelativeSource={RelativeSource AncestorType={x:Type local:RangeSlider}}}"
                      Value="Both">
            <Setter TargetName="TopTick"
                    Property="Visibility"
                    Value="Visible" />
            <Setter TargetName="BottomTick"
                    Property="Visibility"
                    Value="Visible" />
         </DataTrigger>
      </ControlTemplate.Triggers>
   </ControlTemplate>

   <!-- ********************** -->
   <!-- VerticalTickSlider Template     -->
   <!-- ********************** -->
   <ControlTemplate x:Key="VerticalTickSliderTemplate"
                    TargetType="{x:Type Slider}">
      <Grid>
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto" />
         </Grid.ColumnDefinitions>

         <TickBar Name="LeftTick"
                  Grid.Column="0"
                  SnapsToDevicePixels="True"
                  Placement="Left"
                  Fill="Black"
                  Width="4"
                  Visibility="Collapsed" />

         <Border Grid.Column="1"
                 SnapsToDevicePixels="true"
                 Visibility="Hidden">
            <Track x:Name="PART_Track"
                   Orientation="{TemplateBinding Orientation}">
               <Track.Thumb>
                  <Thumb x:Name="Thumb"
                         Focusable="True"
                         Template="{StaticResource ThumbTemplate}">
                  </Thumb>
               </Track.Thumb>
            </Track>
         </Border>

         <TickBar Name="RightTick"
                  Grid.Column="2"
                  SnapsToDevicePixels="True"
                  Fill="Black"
                  Placement="Right"
                  Width="4"
                  Visibility="Collapsed"/>
      </Grid>

      <ControlTemplate.Triggers>
         <DataTrigger Binding="{Binding TickPlacement, RelativeSource={RelativeSource AncestorType={x:Type local:RangeSlider}}}"
                      Value="TopLeft">
            <Setter TargetName="LeftTick"
                    Property="Visibility"
                    Value="Visible" />
         </DataTrigger>
         <DataTrigger Binding="{Binding TickPlacement, RelativeSource={RelativeSource AncestorType={x:Type local:RangeSlider}}}"
                      Value="BottomRight">
            <Setter TargetName="RightTick"
                    Property="Visibility"
                    Value="Visible" />
         </DataTrigger>
         <DataTrigger Binding="{Binding TickPlacement, RelativeSource={RelativeSource AncestorType={x:Type local:RangeSlider}}}"
                      Value="Both">
            <Setter TargetName="LeftTick"
                    Property="Visibility"
                    Value="Visible" />
            <Setter TargetName="RightTick"
                    Property="Visibility"
                    Value="Visible" />
         </DataTrigger>
      </ControlTemplate.Triggers>
   </ControlTemplate>

   <!-- ********************** -->
    <!-- Vertical RangeSlider Template -->
    <!-- ********************** -->
   <ControlTemplate x:Key="VerticalRangeSlider"
                    TargetType="{x:Type local:RangeSlider}">
      <Border BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}"
              Background="{TemplateBinding Background}">
         <Grid HorizontalAlignment="Left"
               VerticalAlignment="Top">
            <Grid.ColumnDefinitions>
               <ColumnDefinition x:Name="LeftColumn"
                                 Width="0"/>
               <ColumnDefinition Width="Auto" />
               <ColumnDefinition x:Name="RightColumn"
                                 Width="0" />
            </Grid.ColumnDefinitions>
            <!-- //#TODODOC 
             Get Thumbs's height to set the good RangeSlider height.-->
            <Grid.RowDefinitions>
               <RowDefinition Height="11" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="11" />
            </Grid.RowDefinitions>

            <Border Grid.Row="1"
                    Grid.RowSpan="3"
                    Grid.Column="1"
                    BorderThickness="1"
                    BorderBrush="#FFD6D6D6"
                    Background="#FFE7EAEA"
                    VerticalAlignment="Stretch"
                    HorizontalAlignment="Center"
                    Width="4" />

            <!-- Create a Hidden Slider to only display its Ticks -->
            <Slider x:Name="TickSlider"
                    Orientation="Vertical"
                    Grid.RowSpan="5"
                    Grid.ColumnSpan="3"
                    Focusable="False"
                    Margin="0,5.5,0,5.5"
                    Template="{StaticResource VerticalTickSliderTemplate}"
                    Minimum="{Binding Minimum, ElementName=PART_LowerSlider}"
                    Maximum="{Binding Maximum, ElementName=PART_HigherSlider}"
                    TickFrequency="{TemplateBinding TickFrequency}">
            </Slider>

            <RepeatButton x:Name="PART_LowerRange"
                          Height="{TemplateBinding LowerRangeWidth}"
                          Grid.Row="3"
                          Grid.Column="1"
                          Background="{TemplateBinding LowerRangeBackground}"
                          Style="{Binding LowerRangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}"
                          SnapsToDevicePixels="True" />

            <RepeatButton Height="{TemplateBinding RangeWidth}"
                          Grid.Row="2"
                          Grid.Column="1"
                          Background="{TemplateBinding RangeBackground}"
                          Style="{Binding RangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}"
                          SnapsToDevicePixels="True" />

            <RepeatButton x:Name="PART_HigherRange"
                          Height="{TemplateBinding HigherRangeWidth}"
                          Grid.Row="1"
                          Grid.Column="1"
                          Background="{TemplateBinding HigherRangeBackground}"
                          Style="{Binding HigherRangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}"
                          SnapsToDevicePixels="True" />

            <!-- Margin is set in CodeBehind, based on HigherSlider's Thumb Height -->
            <Slider x:Name="PART_LowerSlider"
                    Orientation="Vertical"
                    Grid.RowSpan="5"
                    Grid.Column="1"
                    Focusable="False"
                    Background="{TemplateBinding LowerThumbBackground}"
                    Template="{StaticResource SliderTemplate}"
                    IsSnapToTickEnabled="{TemplateBinding IsSnapToTickEnabled}"
                    TickFrequency="{TemplateBinding TickFrequency}"
                    HorizontalAlignment="Left"
                    AutoToolTipPlacement="{TemplateBinding AutoToolTipPlacement}"
                    AutoToolTipPrecision="{TemplateBinding AutoToolTipPrecision}">
            </Slider>

            <!-- Margin is set in CodeBehind, based on LowerSlider's Thumb width -->
            <Slider x:Name="PART_HigherSlider"
                    Grid.RowSpan="5"
                    Grid.Column="1"
                    Orientation="Vertical"
                    Focusable="False"
                    Background="{TemplateBinding HigherThumbBackground}"
                    Template="{StaticResource SliderTemplate}"
                    IsSnapToTickEnabled="{TemplateBinding IsSnapToTickEnabled}"
                    TickFrequency="{TemplateBinding TickFrequency}"
                    HorizontalAlignment="Left"
                    AutoToolTipPlacement="{TemplateBinding AutoToolTipPlacement}"
                    AutoToolTipPrecision="{TemplateBinding AutoToolTipPrecision}">
            </Slider>
         </Grid>
      </Border>
      <ControlTemplate.Triggers>
         <Trigger Property="TickPlacement"
                  Value="TopLeft">
            <Setter TargetName="LeftColumn"
                    Property="Width"
                    Value="4" />
         </Trigger>
         <Trigger Property="TickPlacement"
                  Value="BottomRight">
            <Setter TargetName="RightColumn"
                    Property="Width"
                    Value="4" />
         </Trigger>
         <Trigger Property="TickPlacement"
                  Value="Both">
            <Setter TargetName="LeftColumn"
                    Property="Width"
                    Value="4" />
            <Setter TargetName="RightColumn"
                    Property="Width"
                    Value="4" />
         </Trigger>
      </ControlTemplate.Triggers>
   </ControlTemplate>

    <!-- ********************** -->
    <!-- RangeSlider Style -->
    <!-- ********************** -->
   <Style TargetType="{x:Type local:RangeSlider}">
      <Setter Property="IsTabStop"
              Value="False" />
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:RangeSlider}">
               <Border BorderBrush="{TemplateBinding BorderBrush}"
                       BorderThickness="{TemplateBinding BorderThickness}"
                       Background="{TemplateBinding Background}">
                  <Grid HorizontalAlignment="Left"
                        VerticalAlignment="Top">
                     <Grid.RowDefinitions>
                        <RowDefinition x:Name="TopRow"
                                       Height="0" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition x:Name="BottomRow"
                                       Height="0" />
                     </Grid.RowDefinitions>
                     <!-- //#TODODOC 
                        Get Thumbs's width to set the good RangeSlider width.-->
                     <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="11" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="11" />
                     </Grid.ColumnDefinitions>

                     <Border Grid.Column="1"
                             Grid.ColumnSpan="3"
                             Grid.Row="1"
                             BorderThickness="1"
                             BorderBrush="#FFD6D6D6"
                             Background="#FFE7EAEA"
                             VerticalAlignment="Center"
                             Height="4" />

                     <!-- Create a Hidden Slider to only display its Ticks -->
                     <Slider x:Name="TickSlider"
                             Grid.ColumnSpan="5"
                             Grid.RowSpan="3"
                             Focusable="False"
                             Margin="5.5,0,5.5,0"
                             Template="{StaticResource HorizontalTickSliderTemplate}"
                             Minimum="{Binding Minimum, ElementName=PART_LowerSlider}"
                             Maximum="{Binding Maximum, ElementName=PART_HigherSlider}"
                             TickFrequency="{TemplateBinding TickFrequency}">
                     </Slider>

                     <RepeatButton x:Name="PART_LowerRange"
                                   Width="{TemplateBinding LowerRangeWidth}"
                                   Grid.Column="1"
                                   Grid.Row="1"
                                   Background="{TemplateBinding LowerRangeBackground}"
                                   Style="{Binding LowerRangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}"
                                   SnapsToDevicePixels="True" />

                     <RepeatButton Width="{TemplateBinding RangeWidth}"
                                   Grid.Column="2"
                                   Grid.Row="1"
                                   Background="{TemplateBinding RangeBackground}"
                                   Style="{Binding RangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}"
                                   SnapsToDevicePixels="True" />

                     <RepeatButton x:Name="PART_HigherRange"
                                   Width="{TemplateBinding HigherRangeWidth}"
                                   Grid.Column="3"
                                   Grid.Row="1"
                                   Background="{TemplateBinding HigherRangeBackground}"
                                   Style="{Binding HigherRangeStyle, RelativeSource={RelativeSource TemplatedParent}, TargetNullValue={StaticResource DefaultRangeStyle}}"
                                   SnapsToDevicePixels="True" />

                     <!-- Margin is set in CodeBehind, based on HigherSlider's Thumb width -->
                     <Slider x:Name="PART_LowerSlider"
                             Grid.ColumnSpan="5"
                             Grid.Row="1"
                             Focusable="False"
                             Background="{TemplateBinding LowerThumbBackground}"
                             Template="{StaticResource SliderTemplate}"
                             IsSnapToTickEnabled="{TemplateBinding IsSnapToTickEnabled}"
                             TickFrequency="{TemplateBinding TickFrequency}"
                             AutoToolTipPlacement="{TemplateBinding AutoToolTipPlacement}"
                             AutoToolTipPrecision="{TemplateBinding AutoToolTipPrecision}">
                     </Slider>

                     <!-- Margin is set in CodeBehind, based on LowerSlider's Thumb width -->
                     <Slider x:Name="PART_HigherSlider"
                             Grid.ColumnSpan="5"
                             Grid.Row="1"
                             Focusable="False"
                             Background="{TemplateBinding HigherThumbBackground}"
                             Template="{StaticResource SliderTemplate}"
                             IsSnapToTickEnabled="{TemplateBinding IsSnapToTickEnabled}"
                             TickFrequency="{TemplateBinding TickFrequency}"
                             AutoToolTipPlacement="{TemplateBinding AutoToolTipPlacement}"
                             AutoToolTipPrecision="{TemplateBinding AutoToolTipPrecision}">
                     </Slider>
                  </Grid>
               </Border>
               <ControlTemplate.Triggers>
                  <Trigger Property="TickPlacement"
                           Value="TopLeft">
                     <Setter TargetName="TopRow"
                             Property="Height"
                             Value="4" />
                  </Trigger>
                  <Trigger Property="TickPlacement"
                           Value="BottomRight">
                     <Setter TargetName="BottomRow"
                             Property="Height"
                             Value="4" />
                  </Trigger>
                  <Trigger Property="TickPlacement"
                           Value="Both">
                     <Setter TargetName="TopRow"
                             Property="Height"
                             Value="4" />
                     <Setter TargetName="BottomRow"
                             Property="Height"
                             Value="4" />
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
      <Style.Triggers>
         <Trigger Property="Orientation"
                  Value="Vertical">
            <Setter Property="Template"
                    Value="{StaticResource VerticalRangeSlider}" />
         </Trigger>
      </Style.Triggers>


   </Style>

</ResourceDictionary>
