3

I'm using grouping in WPF (via PropertyGroupDescription in a CollectionViewSource) and displaying the grouped collection in a bound DataGrid.

Typically (as in this MSDN Example) such a DataGrid will display the column headers, followed by each group header (defined in the GroupStyle.Containerstyle), followed by the rows of data in the given group. Here's a quick visual:

 +=====================================================+
 |  ColumnHeader1  |  ColumnHeader2  |  ColumnHeader3  |
 +-----------------+-----------------+-----------------+
 |  Group A                                            |
 +-----------------------------------------------------+
 |   A_Value_11    |   A_Value_12    |   A_Value_13    |
 +-----------------------------------------------------+
 |   A_Value_21    |   A_Value_22    |   A_Value_23    |
 +-----------------+-----------------+-----------------+
 |  Group B                                            |
 +-----------------------------------------------------+
 |   B_Value_11    |   B_Value_12    |   B_Value_13    |
 +-----------------------------------------------------+
 |   B_Value_21    |   B_Value_22    |   B_Value_23    |
 +=====================================================+

Is there a way to make the DataGrid column headers appear/repeat after every group header?

Visually, this is more like what I want:

 +=====================================================+
 |  Group A                                            |
 +-----------------------------------------------------+
 |  ColumnHeader1  |  ColumnHeader2  |  ColumnHeader3  |
 +-----------------------------------------------------+
 |   A_Value_11    |   A_Value_12    |   A_Value_13    |
 +-----------------------------------------------------+
 |   A_Value_21    |   A_Value_22    |   A_Value_23    |
 +-----------------+-----------------+-----------------+
 |  Group B                                            |
 +-----------------------------------------------------+
 |  ColumnHeader1  |  ColumnHeader2  |  ColumnHeader3  |
 +-----------------------------------------------------+
 |   B_Value_11    |   B_Value_12    |   B_Value_13    |
 +-----------------------------------------------------+
 |   B_Value_21    |   B_Value_22    |   B_Value_23    |
 +=====================================================+

Is it possible to do that without too much trouble?

FTLPhysicsGuy
  • 1,035
  • 1
  • 11
  • 23

1 Answers1

0

I would add additional first row for each group containing column headers as text and displayed it with special cell template, e.g. as TextBlock styled like typical column header.

tequilacat
  • 657
  • 1
  • 8
  • 19