<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="CloseButtonTemplate" TargetType="Button">
        <Grid Width="9" Height="9">
            <Border x:Name="CloseButton" BorderBrush="{StaticResource GridViewGroupCellButtonBorder}" BorderThickness="1,1,1,1" CornerRadius="1,1,1,1"
                                                                                Background="{StaticResource GridViewGroupCellCloseButton}" >
                <Path Fill="{StaticResource GridViewGroupPanelButtonCloseIcon}" Stretch="Fill" Stroke="{x:Null}" Margin="0.943,0.834,1.057,1.166" Data="M4,4 L5,4 5,5 4,5 z M0,4 L1,4 1,5 0,5 z M3,3 L4,3 4,4 3,4 z M1,3 L2,3 2,4 1,4 z M2,2 L3,2 3,3 2,3 z M4,0 L5,0 5,1 4,1 4,2 3,2 3,0.99999994 4,0.99999994 z M0,0 L1,0 1,0.99999994 2,0.99999994 2,2 1,2 1,1 0,1 z"/>
            </Border>

        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="CloseButton" Property="Background" Value="{StaticResource GridViewGroupCellButtonBorder_Over}" />
                <Setter TargetName="CloseButton" Property="BorderBrush" Value="{StaticResource GridViewGroupCellCloseButton_OverBorderBrush}" />
            </Trigger>
            <Trigger Property="IsFocused" Value="True"/>
            <Trigger Property="IsDefaulted" Value="True"/>
            <Trigger Property="IsPressed" Value="True"/>
            <Trigger Property="IsEnabled" Value="False"/>
        </ControlTemplate.Triggers>

    </ControlTemplate>

    <Style x:Key="ButtonCloseStyle" TargetType="Button">
        <Setter Property="Template" Value="{StaticResource CloseButtonTemplate}" />
    </Style>

    <ControlTemplate x:Key="GridViewGroupPanelCellTemplate" TargetType="grid:GridViewGroupPanelCell">

        <Border HorizontalAlignment="Left" VerticalAlignment="Top" Height="24" 
				BorderBrush="{StaticResource GridViewGroupPanelCellOuterBorderBrush}" 
				BorderThickness="1,1,1,1" CornerRadius="3,3,3,3" Margin="0,0,0,7">
            <Border BorderThickness="1,1,1,1" CornerRadius="2,2,2,2"
					BorderBrush="{StaticResource GridViewGroupPanelCellInnerBorderBrush}"
					Background="{StaticResource GridViewGroupPanelCellInnerBorderBackground}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="10" />
                        <ColumnDefinition Width="20" />
                    </Grid.ColumnDefinitions>
                    <Path x:Name="PART_SortIndicator" Grid.Column="1"  
						  Fill="{StaticResource GridViewGroupPanelCellSortIndicatorFill}" 
						  Stretch="Fill" HorizontalAlignment="Right" VerticalAlignment="Center" Width="7" Height="4" 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" Margin="0,0,3,0">
                        <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>
                    <Button x:Name="PART_CloseButton"  HorizontalAlignment="Right" VerticalAlignment="Top" Grid.Column="2" Style="{StaticResource ButtonCloseStyle}" Margin="0,3,3,0">

                    </Button>
                    <ContentPresenter Margin="3,0,2,0"  TextElement.FontWeight="Bold" Height="17" Grid.Column="0"
								Content="{Binding DisplayContent}" />
                </Grid>
            </Border>

        </Border>

        <ControlTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=SortDirection}" Value="Ascending">
                <Setter Property="Visibility" TargetName="PART_SortIndicator" Value="Visible" />
                <Setter Property="LayoutTransform" TargetName="PART_SortIndicator">
                    <Setter.Value>
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </Setter.Value>
                </Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=SortDirection}" Value="Descending">
                <Setter Property="Visibility" TargetName="PART_SortIndicator" Value="Visible" />
                <Setter Property="LayoutTransform" TargetName="PART_SortIndicator">
                    <Setter.Value>
                        <ScaleTransform ScaleX="1" ScaleY="1" />
                    </Setter.Value>
                </Setter>
            </DataTrigger>
        </ControlTemplate.Triggers>

    </ControlTemplate>

    <Style 
        
        x:Key="{telerik:ThemeResourceKey ThemeType=local:MyCustomTheme, ElementType=grid:GridViewGroupPanelCell}"
        
        TargetType="grid:GridViewGroupPanelCell">
        <Setter Property="Template" Value="{StaticResource GridViewGroupPanelCellTemplate}" />
    </Style>

</ResourceDictionary>