views:

268

answers:

0

I can style GroupRows by creating a DataGrid.RowGroupHeaderStyles style, but this applies to all GroupRows.

eg If I am grouping by 2 columns. I would like a different background color for column 1 GroupRows and column 2 GroupRows.

Is this possible?

Update

Here's how I've accomplished this, but its a bit of a hack. Hopefully someone will point out a better way.

The default RowGroupHeaderStyles template has a Rectangle that is used to indent each grouping level:

<Rectangle x:Name="IndentSpacer" Grid.Column="1" Grid.Row="1" />

Bearing in mind that I only need style for 2 levels, I can bind the elements that color the row to the Width of the spacer and, using a simple converter, return an appropriate color/brush. eg

Background="{Binding Width, ElementName=IndentSpacer,Converter={StaticResource GroupRowColorFromSpacerConverter}}"

If the Width is 0, its a top level group, anything over 0 and its one level in.