Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
GroupByRecordPresenter - alternate row colors
posted

I have a data presenter in which I group by a column by default. I wanted to alternate the row colors for these group by summary rows. Setting the Highlight Alternate rows property applies only to the standard data row presenters and not the group rows.

I saw that the groupByRecordPresenter class has an IsAlternate property, so I thought this would be easy, and I did the following:

      <Style TargetType="{x:Type igWPF:GroupByRecordPresenter}">
          <Style.Triggers>
              <DataTrigger Binding="{Binding Path=IsAlternate}">
                     <Setter Property="Background" Value="Beige"/>
               </DataTrigger>
           </Style.Triggers>
      </Style>

Which of course, did not work. If I remove the data trigger and just do a SET, only the leftmost portion, the area near the expand button, of the summary row changes its background color.

How do I make the group by record presenters alternate row coloring?

  • 34430
    Offline posted

    Hello Keith,

    The color of the GroupByRecordPresenters is actually determined by a Border that exists in the ControlTemplate for this element named "highlight." This Border has its Background property bound to:

    Background="{DynamicResource {ComponentResourceKey TypeInTargetAssembly={x:Type igDP:XamDataGrid}, ResourceId=LabelHighlight}}"

    If you simply wanted to have a solid color, you could just override this key with your own brush, but being that you are looking to have alternate coloring, I would recommend including the default style for GroupByRecordPresenter. This default style can be found in the DataPresenterGeneric_Express.xaml file commonly found at the following directory:

    C:\Program Files (x86)\Infragistics\<your version here>\WPF\DefaultStyles\DataPresenter

    Once you include this, I would recommend creating a converter and re-binding the "highlight" Border's Background property to the underlying Index property of the underlying GroupByRecord. Using the converter, you can then check this Index for even or odd and return a desired color for your group record.

    I have attached a sample project to demonstrate the above. I hope this helps you.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

    XDGAlternateGroupColorCase.zip