<UserControl x:Class="DataGridSamples.GroupSummary"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
      xmlns:local="clr-namespace:DataGridSamples"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      d:DataContext="{d:DesignData Source=/DesignData/SampleProducts.xaml}"
      d:DesignHeight="274" d:DesignWidth="564">
    <UserControl.Resources>
        <ResourceDictionary>
            <local:Models x:Key="Models"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <c1:C1DataGrid  x:Name="grid" 
                        ItemsSource="{Binding}"
                        CanUserGroup="True"
                        AutoGenerateColumns="True" 
                        AutoGeneratingColumn="grid_AutoGeneratingColumn" 
                        AutoGeneratedColumns="grid_AutoGeneratedColumns"
                        BeginningNewRow="grid_BeginningNewRow"
                        RowHeight="70" 
                        GroupRowHeight="30"
                        FrozenColumnCount="0" 
                        Grid.Row="2">
            <c1:C1GroupingWithSummariesBehavior.GroupingWithSummariesBehavior>
                <c1:C1GroupingWithSummariesBehavior/>
            </c1:C1GroupingWithSummariesBehavior.GroupingWithSummariesBehavior>
        </c1:C1DataGrid>
        <StackPanel Orientation="Horizontal" Margin="0 0 0 10">
                <Button x:Name="btnExpand" Padding="0" Height="22" Content="Expand All" Click="btnExpand_Click" Width="100"/>
                <Button x:Name="btnCollapse" Padding="0" Height="22" Content="Collapse All" Click="btnCollapse_Click" Width="100" Margin="10,0,0,0"/>
                <TextBlock Text="Group By" TextWrapping="Wrap" TextAlignment="Left" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="20,0,0,0"/>
                <ComboBox x:Name="cmbColumns" ItemsSource="{Binding ElementName=grid,Path=Columns}"  Height="22" Margin="6,0,0,0" HorizontalAlignment="Left" Width="140">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Header}"/>
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
        </StackPanel>
    </Grid>
</UserControl>
