<Window x:Class="GroupPanelCheckBox.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"
    xmlns:local="clr-namespace:GroupPanelCheckBox"
    Title="Window1" Height="600" Width="600">
    <Grid>
        <Grid.Resources>

            <Storyboard x:Key="FadeInSelectedRow">
                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="SelectedRow" Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)">
                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#007FB6CA"/>
                    <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#597FB6CA"/>
                </ColorAnimationUsingKeyFrames>
            </Storyboard>

            <Storyboard x:Key="FadeOutSelectedRow">
                <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="SelectedRow" Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)">
                    <SplineColorKeyFrame KeyTime="00:00:00" Value="#597FB6CA"/>
                    <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#007FB6CA"/>
                </ColorAnimationUsingKeyFrames>
            </Storyboard>

            <ControlTemplate x:Key="GridViewExpanderToggleButtonTableTemplate" TargetType="{x:Type ToggleButton}">
                <Border x:Name="Border" Background="#02000000" BorderThickness="0,0,1,0" CornerRadius="0,0,0,0" Padding="6,0,5,0">
                    <Path Fill="#FF000000" StrokeThickness="0" HorizontalAlignment="Center" x:Name="Arrow" VerticalAlignment="Center" SnapsToDevicePixels="True" Data="M1,0L2,0 2,1 3,1 3,2 4,2 4,1 5,1 5,0 6,0 6,1 7,1 7,2 6,2 6,3 5,3 5,4 4,4 4,5 3,5 3,4 2,4 2,3 1,3 1,2 0,2 0,1 1,1 1,0z" Width="7" Height="5" />
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Fill" TargetName="Arrow" Value="#FF027BA8" />
                    </Trigger>
                    <Trigger Property="IsChecked" Value="True">
                        <Setter Property="Data" TargetName="Arrow" Value="M3,0L4,0 4,1 5,1 5,2 6,2 6,3 7,3 7,4 6,4 6,5 5,5 5,4 4,4 4,3 3,3 3,4 2,4 2,5 1,5 1,4 0,4 0,3 1,3 1,2 2,2 2,1 3,1 3,0z" />
                    </Trigger>
                    <Trigger Property="IsEnabled" Value="False">
                        <Setter Property="Foreground" Value="#FF888888" />
                        <Setter Property="Fill" TargetName="Arrow" Value="#FF888888" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>

            <Style TargetType="{x:Type telerik:GridViewExpander}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type telerik:GridViewExpander}">
                            <Grid HorizontalAlignment="Stretch" x:Name="PART_GroupExpanderGrid">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition x:Name="PART_HeaderRow" />
                                    <RowDefinition x:Name="ContentRow" />
                                </Grid.RowDefinitions>
                                <Border x:Name="SelectedRow" Margin="-20, 0, 0, 0" Background="Transparent" Grid.Column="1">
                                    <telerik:HorizontalScrollPanel HorizontalAlignment="Stretch" x:Name="PART_HeaderScroller" Grid.Column="1">
                                        <Border Margin="0,0,0,0" x:Name="PART_GroupExpanderBorder" SnapsToDevicePixels="True" BorderThickness="0,0,0,1" BorderBrush="#19000000">
                                            <Grid x:Name="PART_HeaderGrid">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition />
                                                </Grid.ColumnDefinitions>
                                                <Border x:Name="Border" Background="Transparent" Height="20" Grid.Column="1" Grid.Row="0">
                                                    <Grid Grid.Column="0" Grid.ColumnSpan="1">
                                                        <Grid.ColumnDefinitions>
                                                            <ColumnDefinition Width="Auto"/>
                                                            <ColumnDefinition Width="Auto"/>
                                                            <ColumnDefinition Width="*" />
                                                        </Grid.ColumnDefinitions>
                                                        <ToggleButton OverridesDefaultStyle="True" Grid.Column="0" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Template="{StaticResource GridViewExpanderToggleButtonTableTemplate}">
                                                            <ToggleButton.Background>
                                                                <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                                                    <GradientStop Color="#FFFFFFFF" Offset="0" />
                                                                    <GradientStop Color="#FFCCCCCC" Offset="1" />
                                                                </LinearGradientBrush>
                                                            </ToggleButton.Background>
                                                        </ToggleButton>
                                                        <!-- Add our CheckBox right after the content presenter of -->
                                                        <StackPanel Orientation="Horizontal" Grid.Column="1">
                                                            <ContentPresenter Margin="4,0,4,0" Grid.Column="1" TextBlock.FontWeight="Bold" Content="{TemplateBinding Header}" ContentSource="Header" ContentTemplate="{TemplateBinding HeaderTemplate}" RecognizesAccessKey="True" />
                                                            <!-- When the CheckBox is clicked we execude the ChangeCheckedState command -->
                                                            <CheckBox Content=" Check As Completed" Command="local:Window1.ChangeCheckedStateCommand" CommandParameter="{Binding}"/>
                                                        </StackPanel>
                                                        <telerik:AggregateResultsList HorizontalAlignment="Left" Grid.Column="2">
                                                            <telerik:AggregateResultsList.ItemTemplate>
                                                                <DataTemplate>
                                                                    <telerik:GridViewAggregateResultCell AggregateResult="{Binding}" />
                                                                </DataTemplate>
                                                            </telerik:AggregateResultsList.ItemTemplate>
                                                            <telerik:AggregateResultsList.ItemsPanel>
                                                                <ItemsPanelTemplate>
                                                                    <StackPanel IsItemsHost="True" Orientation="Horizontal" />
                                                                </ItemsPanelTemplate>
                                                            </telerik:AggregateResultsList.ItemsPanel>
                                                        </telerik:AggregateResultsList>
                                                    </Grid>
                                                </Border>
                                            </Grid>
                                        </Border>
                                    </telerik:HorizontalScrollPanel>
                                </Border>
                                <Border x:Name="Content" SnapsToDevicePixels="True" Background="#00FFFFFF" CornerRadius="0,0,0,0" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1">
                                    <ContentPresenter Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />

                                </Border>
                                <telerik:NavigationPresenter x:Name="PART_NavigationPresenter" VerticalAlignment="Stretch" />
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsExpanded" Value="False">
                                    <Setter Property="Visibility" TargetName="Content" Value="Collapsed" />
                                </Trigger>
                                <Trigger Property="IsEnabled" Value="False">
                                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                                </Trigger>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard Storyboard="{StaticResource FadeInSelectedRow}" />
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard Storyboard="{StaticResource FadeOutSelectedRow}" />
                                    </Trigger.ExitActions>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        <telerik:RadGridView Name="RadGridView1">
            <telerik:RadGridView.GroupDescriptions>
                <telerik:RadGroupDescription PropertyName="Size"/>
            </telerik:RadGridView.GroupDescriptions>
        </telerik:RadGridView>
    </Grid>
</Window>