<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
		xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:local="clr-namespace:CustomTheme;assembly=CustomTheme"
        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">
        <Grid x:Name="PART_HeaderCellGrid" MinHeight="{TemplateBinding MinHeight}">
            <Grid.Resources>
                <BooleanToVisibilityConverter x:Key="booleanConverter" />
            </Grid.Resources>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

            <Border x:Name="GridViewHeaderCell" Grid.ColumnSpan="2" SnapsToDevicePixels="True"
							Margin="{TemplateBinding Margin}"
							Background="{TemplateBinding Background}"
							BorderBrush="{TemplateBinding BorderBrush}" 
							BorderThickness="{TemplateBinding BorderThickness}" />

            <Border x:Name="GridViewHeaderCell_Over" Grid.ColumnSpan="2" Opacity="0" SnapsToDevicePixels="True"
							Margin="{TemplateBinding Margin}"
							Background="{StaticResource GridViewHeaderCellInnerBorderBackground_Over}"
							BorderBrush="{TemplateBinding BorderBrush}" 
							BorderThickness="{TemplateBinding BorderThickness}" />

            <Border x:Name="GridViewHeaderCell_Selected" Grid.ColumnSpan="2" Opacity="0" SnapsToDevicePixels="True"
							Margin="{TemplateBinding Margin}"
							Background="{StaticResource GridViewHeaderCellInnerBorderBackground_Selected}"
							BorderBrush="{TemplateBinding BorderBrush}"  
							BorderThickness="{TemplateBinding BorderThickness}" />

            <grid:AlignmentContentPresenter TextAlignment="{TemplateBinding TextAlignment}" 
							Margin="{TemplateBinding Padding}" 
							HorizontalAlignment="{TemplateBinding HorizontalAlignment}" 
							VerticalAlignment="{TemplateBinding VerticalAlignment}" />

            <Grid Grid.Column="1" HorizontalAlignment="Right">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <Path x:Name="PART_SortIndicator" Stretch="Fill" HorizontalAlignment="Right" VerticalAlignment="Center" Width="7" Height="4" Margin="1,0,4,0" Data="M0,0 L1,0 2,0 3,0 4,0 5,0 5.9999999,0 7,0 7,0.99999996 5.9999999,0.99999996 5,0.99999996 5.9999999,1.0000001 5.9999999,2 5,2 4.981,2 4.981,3 4,3 3.9809999,3 3.9809999,4 2.9809999,4 2.9809999,3 2,3 2,2 1,2&#xa;1,1.0000001 0,1.0000001 z" RenderTransformOrigin="0.5,0.5"
						Fill="{StaticResource GridViewHeaderCellSortIndicator}" Visibility="Visible">
                    <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>

        <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:MyCustomTheme, ElementType=grid:GridViewHeaderCell}"
        
        TargetType="grid:GridViewHeaderCell">

        <Setter Property="Template" Value="{StaticResource GridViewHeaderCellTemplate}" />
        <Setter Property="Background" Value="{StaticResource GridViewHeaderCellInnerBorderBackground}" />
        <Setter Property="BorderBrush" Value="{StaticResource GridViewHeaderCellInnerBorderBrush}" />
        <Setter Property="BorderThickness" Value="0,0,1,1" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="MinHeight" Value="26" />
        <Setter Property="Padding" Value="3,0,3,0" />
        <Setter Property="Foreground" Value="#FF333333" />
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="FontStyle" Value="Normal" />
        <Setter Property="FontSize" Value="11" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="VerticalAlignment" Value="Center" />
        <Setter Property="DropMarkPen" Value="{StaticResource GridViewHeaderCellDropMarkerPen}" />


    </Style>
    
</ResourceDictionary>