<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:local="clr-namespace:CustomThemeBasedOnOfficeBlack_GridWpf;assembly=CustomThemeBasedOnOfficeBlack_GridWpf"
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                    
    
    xmlns:grid="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
    xmlns:controls="clr-namespace:Telerik.Windows.Controls"
    
     >
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Resources.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    

    <ControlTemplate x:Key="GridViewHeaderCellTemplate" TargetType="grid:GridViewHeaderCell">
        
        <ControlTemplate.Resources>
			<Storyboard x:Key="MouseOver">
				<DoubleAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetName="GridViewHeaderCell_Over" Storyboard.TargetProperty="Opacity">
					<SplineDoubleKeyFrame KeyTime="0:0:0.12" Value="1" />
				</DoubleAnimationUsingKeyFrames>
			</Storyboard>
			<Storyboard x:Key="MouseOut">
				<DoubleAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetName="GridViewHeaderCell_Over" Storyboard.TargetProperty="Opacity">
					<SplineDoubleKeyFrame KeyTime="0:0:0.12" Value="0" />
				</DoubleAnimationUsingKeyFrames>
			</Storyboard>
		</ControlTemplate.Resources>
        
		<Grid>
			<Border x:Name="GridViewHeaderCell"
					BorderBrush="{TemplateBinding BorderBrush}" 
					BorderThickness="{TemplateBinding BorderThickness}"
					Background="{TemplateBinding Background}"
					
					SnapsToDevicePixels="True"
					 />
			<Border x:Name="GridViewHeaderCell_Over"
					BorderBrush="{StaticResource GridViewHeaderCellMouseOverBorderBrush}" 
					BorderThickness="{TemplateBinding BorderThickness}"
					Background="{StaticResource GridViewHeaderCellSortedBackground}"
					Opacity="0"
					
					SnapsToDevicePixels="True"
					 />
			<Border x:Name="GridViewHeaderCell_Selected"
					BorderBrush="{StaticResource GridViewHeaderCellMouseOverBorderBrush}" 
					BorderThickness="{TemplateBinding BorderThickness}"
					Background="{StaticResource GridViewHeaderCellSortedBackground}"
					Opacity="0"
					
					SnapsToDevicePixels="True"
					 />

				<Grid x:Name="PART_HeaderCellGrid">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="*" />
						<ColumnDefinition Width="Auto"  />
					</Grid.ColumnDefinitions>

					<grid:AlignmentContentPresenter Grid.Column="0" 
													Margin="3,4,2,3"
													VerticalAlignment="Center"
													TextAlignment="{TemplateBinding TextAlignment}" 
													
													TextBlock.FontWeight="Bold"
													 />

						<Grid Grid.Column="1" HorizontalAlignment="Right" 
							  Background="{StaticResource GridViewHeaderCellSortingAndFilteringContentBackground}">
							<Grid.ColumnDefinitions>
								<ColumnDefinition Width="Auto"/>
								<ColumnDefinition Width="Auto" />
							</Grid.ColumnDefinitions>

							<Path x:Name="PART_SortIndicator" Fill="{StaticResource GridViewHeaderCellSortIndicatorFill}" Stretch="Fill" Data="M0,0 L1,0 2,0 3,0 4,0 5,0 5,1 4,1 4,2 3,2 3,3 2,3 2,2 1,2 1,1 0,1 0,0 z" HorizontalAlignment="Left" Margin="1,0,4,0" VerticalAlignment="Center" Width="5" Height="3" RenderTransformOrigin="0.5,0.5" >
								<Path.RenderTransform>
									<TransformGroup>
										<ScaleTransform ScaleX="1" ScaleY="-1"/>
										<SkewTransform AngleX="0" AngleY="0"/>
										<RotateTransform Angle="0"/>
										<TranslateTransform X="0" Y="0"/>
									</TransformGroup>
								</Path.RenderTransform>
							</Path>

							<grid:FilteringDropDown Name="PART_DistinctFilterControl" Grid.Column="1"
													Visibility="{TemplateBinding FilteringUIVisibility}"
													 Margin="0,0,8,0"/>

						</Grid>
				</Grid>
				
		</Grid>
		
        <ControlTemplate.Triggers>

			<MultiTrigger>
				<MultiTrigger.EnterActions>
					<BeginStoryboard Storyboard="{StaticResource MouseOver}" />
				</MultiTrigger.EnterActions>
				<MultiTrigger.ExitActions>
					<BeginStoryboard Storyboard="{StaticResource MouseOut}" />
				</MultiTrigger.ExitActions>
				<MultiTrigger.Conditions>
					<Condition Property="IsMouseOver" Value="True" />
					<Condition Property="SortingState" Value="None" />
				</MultiTrigger.Conditions>
			</MultiTrigger>
			
			<Trigger Property="SortingState" Value="Ascending">
                <Setter TargetName="PART_SortIndicator" Property="Path.Visibility" Value="Visible" />
                <Setter TargetName="PART_SortIndicator" Property="Path.LayoutTransform" >
                    <Setter.Value>
                        <ScaleTransform ScaleX="1" ScaleY="1"/>
                    </Setter.Value>
                </Setter>
                <Setter Property="Opacity" TargetName="GridViewHeaderCell_Selected" Value="1" />
            </Trigger>
            <Trigger Property="SortingState" Value="Descending">
                <Setter TargetName="PART_SortIndicator" Property="Path.Visibility" Value="Visible" />
                <Setter TargetName="PART_SortIndicator" Property="Path.LayoutTransform" >
                    <Setter.Value>
                        <ScaleTransform ScaleX="1" ScaleY="-1"/>
                    </Setter.Value>
                </Setter>
                <Setter Property="Opacity" TargetName="GridViewHeaderCell_Selected" Value="1" />
            </Trigger>
            <Trigger Property="SortingState" Value="None">
                <Setter TargetName="PART_SortIndicator" Property="Path.Visibility" Value="Hidden" />
            </Trigger>
        </ControlTemplate.Triggers>
        

    </ControlTemplate>

    <Style 
        
        x:Key="{telerik:ThemeResourceKey ThemeType=local:CustomTheme, ElementType=grid:GridViewHeaderCell}"
        
        TargetType="grid:GridViewHeaderCell">

        <Setter Property="Template" Value="{StaticResource GridViewHeaderCellTemplate}" />
        
		<Setter Property="Background" Value="{StaticResource GridViewHeaderBackground}" />
        <Setter Property="BorderThickness" Value="0,0,2,1" />
        <Setter Property="BorderBrush" Value="{StaticResource GridViewHeaderCellInnerBorderBrush}" />
		
		
        <Setter Property="DropMarkPen" Value="{StaticResource GridViewHeaderCellDropMarkerPen}" />
        
		
    </Style>
    
</ResourceDictionary>