title: How can I Group Data in WPF Toolkid Datagrid That is Bound to a Datatable
body: <p>I'm a newer to wpf. I'm developing a small application using wpf in .net 3.5. I have a wpf toolkid datagrid control that is bound with a datatable. Now I'm unable to group data on my datagrid.</p>
  
  <p>who can tell me how can i accomplish this?</p>
  
  <p>Here is my xmal</p>
  
  <pre><code>        &lt;Window.Resources&gt;
          &lt;Style x:Key="GroupHeaderStyle" TargetType="{x:Type GroupItem}"&gt;
                      &lt;Setter Property="Template"&gt;
                          &lt;Setter.Value&gt;
                              &lt;ControlTemplate TargetType="{x:Type GroupItem}"&gt;
                                  &lt;Expander x:Name="exp" IsExpanded="True"
                                    Background="White"
                                    Foreground="Black"&gt;
                                      &lt;Expander.Header&gt;
                                          &lt;TextBlock Text="{Binding AdmissionDate}"/&gt;
                                      &lt;/Expander.Header&gt;
                                      &lt;ItemsPresenter /&gt;
                                  &lt;/Expander&gt;
                              &lt;/ControlTemplate&gt;
                          &lt;/Setter.Value&gt;
                      &lt;/Setter&gt;
                  &lt;/Style&gt;
              &lt;/Window.Resources&gt;
  
  &lt;tk:DataGrid Grid.Row="2" Grid.ColumnSpan="4" Margin="5,0,5,0"
                       AutoGenerateColumns="False" 
                       Name="testTakerGrid" 
                       AlternationCount="2" 
                       AlternatingRowBackground="Azure"
                       RowHeaderWidth="40"
                       CanUserSortColumns="True"
                       IsSynchronizedWithCurrentItem="True"
                       GridLinesVisibility="None"
                       ItemsSource="{Binding}"
                       SelectionMode="Single"
                       CanUserAddRows="False" CanUserDeleteRows="False"&gt;
           &lt;tk:DataGrid.GroupStyle&gt;
                          &lt;GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}"&gt;
                              &lt;GroupStyle.Panel&gt;
                                  &lt;ItemsPanelTemplate&gt;
                                      &lt;tk:DataGridRowsPresenter/&gt;
                                  &lt;/ItemsPanelTemplate&gt;
                              &lt;/GroupStyle.Panel&gt;
                          &lt;/GroupStyle&gt;
                      &lt;/tk:DataGrid.GroupStyle&gt;
  &lt;tk:DataGrid.Columns&gt;                
          &lt;tk:DataGridTextColumn Header="Serial Id" Binding="{Binding Path=SerialId, Mode=OneWay, ValidatesOnDataErrors=True}" Width="60"/&gt;              
          &lt;tk:DataGridTextColumn Header="Name" Binding="{Binding Path=Name, Mode=OneWay, ValidatesOnExceptions=True}" Width="200"/&gt;
          &lt;tk:DataGridTextColumn Header="Gender" Binding="{Binding Path=Gender, Mode=OneWay, ValidatesOnExceptions=True}"/&gt;
          &lt;tk:DataGridTextColumn Header="Admission Date" Binding="{Binding Path=AdmissionDate, Mode=OneWay, ValidatesOnExceptions=True, StringFormat='d'}" Width="100" /&gt;
  &lt;/tk:DataGrid.Columns&gt;
  &lt;/tk:DataGrid&gt;
  </code></pre>
  
  <p>Here is my code behide</p>
  
  <pre><code>    public partial class MainApp : Window
      {
          TestTakerDataSet takerDs = new TestTakerDataSet();
          TestTakersTableAdapter takerTa = new TestTakersTableAdapter();
  
          CollectionView view;
          private void Window_Loaded(object sender, RoutedEventArgs e)
          {
                   takerTa.FillByTerm(takerDs.TestTakers, "2010-2011T1E");        
  
                          view = (CollectionView)CollectionViewSource.GetDefaultView(takerDs.TestTakers);
  this.DataContext=view;
          }
  
      }
  </code></pre>