Search code examples
c#wpfxamlwpftoolkitxceed-datagrid

Xceed Datagrid set GroupHeaderControl Template for a single GroupHeader instead of all GroupHeaders


The documentation boasts this "wonderful" example of how to style the group headers.

<Style TargetType="{x:Type xcdg:GroupHeaderControl}">
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="{x:Type xcdg:GroupHeaderControl}">
        <Border Background="Orange" BorderThickness="2">
          <StackPanel Orientation="Horizontal">
            <CheckBox IsChecked="{Binding RelativeSource={RelativeSource
                                  TemplatedParent}, Path=Group.IsExpanded}"/>
            <ContentPresenter/>
          </StackPanel>
        </Border>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

The problem is that this applies the template globally to all Grids and all Groups.

What I would really really really like to know is, how to specify the Template to use for the GroupHeaderControl for just 1 group?

Something like: (Does not work)

<xcdg:Column Title="Station" FieldName="Station">                         
    <xcdg:Column.GroupConfiguration>
        <xcdg:GroupConfiguration UseDefaultHeadersFooters="False" >                                
            <xcdg:GroupConfiguration.Headers>
                <xcdg:GroupHeaderControl Template="{StaticResource customtableViewGroupHeaderControlTemplate}" />
                <xcdg:GroupHeaderFooterItemTemplate VisibleWhenCollapsed="True" />
            </xcdg:GroupConfiguration.Headers>
        </xcdg:GroupConfiguration>
    </xcdg:Column.GroupConfiguration>
</xcdg:Column>

Does anyone know how to address this?


Solution

  • I found an answer almost by accident. To set this template individually you must do the following:

    In your resources add the following:

     <DataTemplate x:Key="GroupByTest">
            <xcdg:GroupHeaderControl Template="{StaticResource MyGroupHeaderControlTemplate}" />
     </DataTemplate>
    

    Doing this will allow you set the individual Group Headers Template. However doing this seems to create a whole slew of other little issues that have to be resolved.