<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>
    

    
    <Style x:Key="ExpanderDownHeaderStyle" TargetType="ToggleButton">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ToggleButton">
                    <Grid Background="Transparent">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="24" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>

                        <Path x:Name="plus" 
							  Fill="{StaticResource GridViewExpanderToggleButtonFill}" Stretch="Fill" RenderTransformOrigin="0.5,0.5" Data="M3,0 L5,0 5,3 8,3 8,5 5,5 5,8 3,8 3,5 0,5 0,3 3,3 z" HorizontalAlignment="Center" VerticalAlignment="Center" Width="8" Height="8">
                            <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>
                        <Rectangle x:Name="minus" Visibility="Collapsed" 
								   Fill="{StaticResource GridViewExpanderToggleButtonFill}" HorizontalAlignment="Center" VerticalAlignment="Center" Width="8" Height="2"/>

                        <ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Left" Margin="4,0,0,0" VerticalAlignment="Center" Grid.Column="1" RecognizesAccessKey="True" />
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsChecked" Value="true">
                            <Setter Property="Visibility" TargetName="plus" Value="Collapsed"/>
                            <Setter Property="Visibility" TargetName="minus" Value="Visible"/>
                        </Trigger>
                    </ControlTemplate.Triggers>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="GridViewExpandableRowExpanderStyle" TargetType="telerik:RadExpander">
        <Setter Property="Foreground" Value="{StaticResource GridViewExpandableRowForeground}"/>
        <Setter Property="Background" Value="{StaticResource GridViewExpandableRowBackground}"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="TemplateDown">
            <Setter.Value>
                <ControlTemplate TargetType="telerik:RadExpander">
                    <Border SnapsToDevicePixels="true" VerticalAlignment="Stretch" Background="Transparent" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                        <DockPanel>
                            <StackPanel x:Name="HeaderSite" DockPanel.Dock="Top" Orientation="Horizontal"
                                TextBlock.FontSize="{TemplateBinding FontSize}" 
								TextBlock.FontStretch="{TemplateBinding FontStretch}" 
								TextBlock.FontStyle="{TemplateBinding FontStyle}" 
								TextBlock.FontWeight="{TemplateBinding FontWeight}" 
								TextBlock.Foreground="{TemplateBinding Foreground}" 
							    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
								VerticalAlignment="{TemplateBinding VerticalContentAlignment}" >

                                <ToggleButton x:Name="HeaderButton" IsTabStop="False"
                                              FontFamily="{TemplateBinding FontFamily}"
                                              Padding="{TemplateBinding Padding}" 
                                              Style="{StaticResource ExpanderDownHeaderStyle}" 
								              IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>

                                <ContentPresenter 
                                    VerticalAlignment="Center" 
                                    HorizontalAlignment="Left" 
                                    Content="{TemplateBinding Header}" 
                                    ContentTemplate="{TemplateBinding HeaderTemplate}" 
                                    ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"/>

                            </StackPanel>

                            <grid:HorizontalScrollPanel x:Name="PART_ChildScrollContainer" >
                                <Border x:Name="borderExpandSite"  
										BorderBrush="{StaticResource GridViewExpandableRowExpandSiteBorderBrush}" 
										Background="{StaticResource GridViewExpandableRowExpandSiteBackground}" BorderThickness="0,0,1,0">
                                    <ContentPresenter  Focusable="false" 
												MinHeight="{TemplateBinding MinHeight}"
											   Visibility="Collapsed" 
											   HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
											   Margin="{TemplateBinding Padding}" 
											   x:Name="ExpandSite"
											   VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
											   DockPanel.Dock="Bottom"/>
                                </Border>
                            </grid:HorizontalScrollPanel>
                        </DockPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsExpanded" Value="true">
                            <Setter Property="Visibility" TargetName="ExpandSite" Value="Visible"/>
                            <Setter TargetName="borderExpandSite" Property="BorderThickness" Value="0,0,1,1" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>



    <ControlTemplate x:Key="HierarchyChildPresenterTemplate" TargetType="grid:HierarchyChildPresenter">
        <telerik:RadExpander x:Name="PART_Expander"
                                 IsExpanded="{Binding Path=IsExpanded, Mode=TwoWay}"
                                 Style="{StaticResource GridViewExpandableRowExpanderStyle}">
            <telerik:RadExpander.Header>
                <StackPanel Orientation="Horizontal">
                    <grid:GridViewCellsPanel x:Name="PART_FrozenGridViewCellsPanel"/>
                    <grid:FrozenColumnsSplitter  x:Name="PART_FrozenColumnsSplitter" />
                    <grid:HorizontalScrollPanel x:Name="PART_PartialScrollContainer" >
                        <grid:GridViewCellsPanel x:Name="PART_GridViewCellsPanel" MinHeight="{TemplateBinding MinHeight}" />
                    </grid:HorizontalScrollPanel>
                </StackPanel>
            </telerik:RadExpander.Header>
        </telerik:RadExpander>
    </ControlTemplate>



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

        <Setter Property="Template" Value="{StaticResource HierarchyChildPresenterTemplate}" />
		<!-- Sets the height of the expandable row: Default is 24 -->
		<Setter Property="MinHeight" Value="24" />
    </Style>
    

</ResourceDictionary>