<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>
            <Color x:Key="GridViewBackgroundColor">#FF535353</Color>
            <Color x:Key="GridViewIndicatorsPartsFillGradientStop1">#FF000000</Color>
            <Color x:Key="GridViewIndicatorsPartsFillGradientStop2">#FF000000</Color>

            <SolidColorBrush x:Key="HierarchyChildPresenterBorderBrush" Color="{StaticResource GridViewElementOuterBorderBrushColor}" />
            <SolidColorBrush x:Key="HierarchyChildPresenterBackground" Color="{StaticResource GridViewHierarchyAndGroupingColor}" />
            <SolidColorBrush x:Key="HierarchyChildPresenterToggleButtonBorderBrush" Color="{StaticResource GridViewElementOuterBorderBrushColor}" />
            <SolidColorBrush x:Key="HierarchyChildPresenterToggleButtonFill" Color="{StaticResource GridViewBackgroundColor}" />
            <LinearGradientBrush x:Key="GridViewIndicatorsPartsFill" EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="{StaticResource GridViewIndicatorsPartsFillGradientStop1}" Offset="0"/>
                <GradientStop Color="{StaticResource GridViewIndicatorsPartsFillGradientStop2}" Offset="1"/>
            </LinearGradientBrush>

            <Style x:Key="ExpanderDownHeaderStyle" TargetType="ToggleButton">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ToggleButton">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Border x:Name="minus" Visibility="Collapsed" HorizontalAlignment="Left" Width="26" VerticalAlignment="Stretch" Background="Transparent"
								BorderBrush="{StaticResource HierarchyChildPresenterToggleButtonBorderBrush}" BorderThickness="0,1,1,1" Margin="0,-1,0,0">
                                    <Rectangle Fill="{StaticResource GridViewIndicatorsPartsFill}" Stroke="{x:Null}" VerticalAlignment="Center" Width="8" Height="2" Margin="8,11,9,10"/>
                                </Border>
                                <Border x:Name="plus" HorizontalAlignment="Left" Width="26" VerticalAlignment="Stretch" Background="Transparent"
								BorderBrush="{StaticResource HierarchyChildPresenterToggleButtonBorderBrush}" BorderThickness="0,1,1,1" Margin="0,-1,0,0">
                                    <Path Fill="{StaticResource GridViewIndicatorsPartsFill}" Stretch="Fill" Width="8" Height="8" VerticalAlignment="Center" Stroke="{x:Null}" Margin="8,8,9,7" 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">
                                        <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>
                                </Border>
                                <ContentPresenter SnapsToDevicePixels="True" HorizontalAlignment="Left" Margin="0,0,0,0" Grid.Column="1" RecognizesAccessKey="True" Height="{TemplateBinding MinHeight}" />
                            </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="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}" 
                                              Click="HeaderButton_Click"
                                              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>

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