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

   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:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes"
                    xmlns:local="clr-namespace:Xceed.Wpf.Toolkit">

   <DataTemplate x:Key="DefaultWatermarkTemplate">
      <ContentControl Content="{Binding}"
                      Foreground="Gray"
                      Focusable="False"
                      Margin="0,0,3,0" />
   </DataTemplate>

   <!-- =============================================================================== -->
   <!-- TimeSpanUpDown                                                                  -->
   <!-- =============================================================================== -->

   <Style x:Key="TimeSpanUpDown"
          TargetType="{x:Type local:TimeSpanUpDown}">
      <Setter Property="Background"
              Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
      <Setter Property="BorderBrush"
              Value="{DynamicResource {x:Static themes:ResourceKeys.ControlNormalBorderKey}}" />
      <Setter Property="BorderThickness"
              Value="1" />
      <Setter Property="Foreground"
              Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
      <Setter Property="HorizontalContentAlignment"
              Value="Right" />
      <Setter Property="VerticalContentAlignment"
              Value="Center" />
      <Setter Property="TextAlignment"
              Value="Right" />
      <Setter Property="WatermarkTemplate"
              Value="{StaticResource DefaultWatermarkTemplate}" />
      <Setter Property="IsTabStop"
              Value="False" />
      <Setter Property="Template">
         <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:TimeSpanUpDown}">
               <local:ButtonSpinner x:Name="PART_Spinner"
                                    IsTabStop="False"
                                    Background="{TemplateBinding Background}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    HorizontalContentAlignment="Stretch"
                                    VerticalContentAlignment="Stretch"
                                    ButtonSpinnerLocation="{TemplateBinding ButtonSpinnerLocation}"
                                    AllowSpin="{TemplateBinding AllowSpin}"
                                    ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}">
                  <local:WatermarkTextBox x:Name="PART_TextBox"
                                          BorderThickness="0"
                                          Background="Transparent"
                                          ContextMenu="{TemplateBinding ContextMenu}"
                                          FontFamily="{TemplateBinding FontFamily}"
                                          FontSize="{TemplateBinding FontSize}"
                                          FontStretch="{TemplateBinding FontStretch}"
                                          FontStyle="{TemplateBinding FontStyle}"
                                          FontWeight="{TemplateBinding FontWeight}"
                                          Foreground="{TemplateBinding Foreground}"
                                          HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                                          IsUndoEnabled="{Binding IsUndoEnabled, RelativeSource={RelativeSource TemplatedParent}}"
                                          IsTabStop="True"
                                          MinWidth="20"
                                          AcceptsReturn="False"
                                          Padding="{TemplateBinding Padding}"
                                          TextAlignment="{TemplateBinding TextAlignment}"
                                          TextWrapping="NoWrap"
                                          TabIndex="{TemplateBinding TabIndex}"
                                          Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}"
                                          Watermark="{TemplateBinding Watermark}"
                                          WatermarkTemplate="{TemplateBinding WatermarkTemplate}" />
               </local:ButtonSpinner>
               <ControlTemplate.Triggers>
                  <MultiDataTrigger>
                     <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsReadOnly, RelativeSource={RelativeSource Self}}"
                                   Value="False" />
                        <Condition Binding="{Binding AllowTextInput, RelativeSource={RelativeSource Self}}"
                                   Value="False" />
                     </MultiDataTrigger.Conditions>
                     <Setter Property="IsReadOnly"
                             Value="True"
                             TargetName="PART_TextBox" />
                  </MultiDataTrigger>
                  <DataTrigger Binding="{Binding IsReadOnly, RelativeSource={RelativeSource Self}}"
                               Value="True">
                     <Setter Property="IsReadOnly"
                             Value="True"
                             TargetName="PART_TextBox" />
                  </DataTrigger>
                  <Trigger Property="IsFocused"
                           Value="True">
                     <Setter TargetName="PART_TextBox"
                             Property="FocusManager.FocusedElement"
                             Value="{Binding ElementName=PART_TextBox}" />
                  </Trigger>
                  <Trigger Property="IsEnabled"
                           Value="False">
                     <Setter Property="Foreground"
                             Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                  </Trigger>
               </ControlTemplate.Triggers>
            </ControlTemplate>
         </Setter.Value>
      </Setter>
   </Style>

   <Style TargetType="{x:Type local:TimeSpanUpDown}"
          BasedOn="{StaticResource TimeSpanUpDown}" />

</ResourceDictionary>
