<Window x:Class="RadGridViewWpf_2009_Q1SP11.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <Grid.Resources>

            <Color x:Key="GridViewElementOuterBorderBrushColor">#FFB3B3B3</Color>
            <Color x:Key="GridViewHierarchyAndGroupingColor">#FFFDDFAA</Color>
            
            <SolidColorBrush x:Key="HierarchyChildPresenterBorderBrush" Color="{StaticResource GridViewElementOuterBorderBrushColor}" />
            <SolidColorBrush x:Key="HierarchyChildPresenterBackground" Color="{StaticResource GridViewHierarchyAndGroupingColor}" />

            <Style x:Key="GridViewExpandableRowExpanderStyle" TargetType="telerik:RadExpander">
                <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}" 
                                              
								              IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>-->

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

                                    </StackPanel>

                                    <Rectangle Fill="Transparent" x:Name="PART_HierarchyRowTopLine" HorizontalAlignment="Stretch" Height="0" DockPanel.Dock="Top"/>
                                    <Rectangle Fill="Transparent" x:Name="PART_HierarchyRowBottomLine" HorizontalAlignment="Stretch" Height="0" DockPanel.Dock="Bottom"/>
                                    <Border x:Name="borderExpandSite"  BorderBrush="{StaticResource HierarchyChildPresenterBorderBrush}" Background="{StaticResource HierarchyChildPresenterBackground}" BorderThickness="0,0,1,0">
                                        <telerik:HorizontalScrollPanel x:Name="PART_ChildScrollContainer">
                                            <ContentPresenter  Focusable="false"
									Visibility="Collapsed" 
									HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
									Margin="{TemplateBinding Padding}" 
									x:Name="ExpandSite" 
									VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
									DockPanel.Dock="Bottom" />
                                        </telerik:HorizontalScrollPanel>
                                    </Border>
                                </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="IsExpanded" Value="false">
                                    <Setter TargetName="PART_HierarchyRowTopLine" Property="Visibility" Value="Collapsed"/>
                                    <Setter TargetName="PART_HierarchyRowBottomLine" Property="Visibility" Value="Collapsed"/>
                                </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="telerik:HierarchyChildPresenter">
                <telerik:RadExpander x:Name="PART_Expander" Style="{StaticResource GridViewExpandableRowExpanderStyle}"
                                 IsExpanded="{Binding Path=IsExpanded, Mode=TwoWay}" 
                                 >
                    <telerik:RadExpander.Header>
                        <StackPanel Orientation="Horizontal">
                            <telerik:GridViewCellsPanel x:Name="PART_FrozenGridViewCellsPanel"/>
                            <telerik:FrozenColumnsSplitter  x:Name="PART_FrozenColumnsSplitter"  />
                            <telerik:HorizontalScrollPanel x:Name="PART_PartialScrollContainer"  >
                                <telerik:GridViewCellsPanel x:Name="PART_GridViewCellsPanel" Height="Auto" MinHeight="{TemplateBinding MinHeight}" />
                            </telerik:HorizontalScrollPanel>
                        </StackPanel>
                    </telerik:RadExpander.Header>
                </telerik:RadExpander>
            </ControlTemplate>

            <Style TargetType="telerik:HierarchyChildPresenter">
                <Setter Property="Template" Value="{StaticResource HierarchyChildPresenterTemplate}" />
                <Setter Property="MinHeight" Value="24" />
            </Style>
            
        </Grid.Resources>
        
		<telerik:RadGridView Name="RadGridView1" SelectionChanged="RadGridView1_SelectionChanged" ></telerik:RadGridView>
    </Grid>
</Window>
