Custom style on Group Summary Cell based on default style

Hello,

I'm trying to create a style for the Group Summary Cell. I has able to create it following this link on the KB: https://www.syncfusion.com/kb/2485/how-to-set-the-horizontal-alignment-on-summary-columns .

The style I create is the following:

<Style x:Key="GridGroupSummaryRight"
       TargetType="syncfusion:GridGroupSummaryCell">
    <Setter Property="HorizontalAlignment" Value="Right" />
    <Setter Property="FontWeight" Value="DemiBold" />
</Style>

But the style is now inconsistent with the rest of the DataGrid (using MaterialLight as theme) as shown in the following capture:

Image_8230_1741870092635

The inconsistency is on the lines (different color and lenght) and should look more like in this other capture (no custom style):

Image_7535_1741870202582


So I though about use a "BasedOn" property on the style but can't find the resource " GridGroupSummaryCellStyle".

<Style x:Key="GridGroupSummaryRight"
       BasedOn="{StaticResource GridGroupSummaryCellStyle}"
       TargetType="syncfusion:GridGroupSummaryCell">
    <Setter Property="HorizontalAlignment" Value="Right" />
    <Setter Property="FontWeight" Value="DemiBold" />
</Style>


Which is the base style resource name that should be used? Or which is the approach to achive the consitency with the rest of the style and only change the text alignment and font weight?


Thanks in advance.


3 Replies

SB Sweatha Bharathi Syncfusion Team March 14, 2025 12:49 PM UTC

Hi David García ,

We have reviewed your query and noticed that an incorrect key was provided for the GridGroupSummaryCell. Based on the information you provided, we have prepared a sample. We have applied a style for the GridGroupSummaryCell and used the MaterialLight theme. The styles are correctly applied when the theme is in use. We have merged the theme into the ResourceDictionary and overridden the style using the BasedOn property.
In the ResourceDictionary, specify the style path that needs to be overridden, and in the BasedOn property, reference the appropriate key. Please note that we maintain a consistent key across all themes.
It is important to set the correct theme path in the ResourceDictionary, as this will ensure the theme is applied to the control and the appropriate key is used. The SetTheme method helps apply the theme but does not handle key assignments.
We have provided a sample for your reference. Kindly review it, and if you are still encountering issues, please modify the sample to reflect your scenario and provide additional details on how you have set the theme for the DataGrid. This will help us assist you further and provide better solution.


Code snippet :

 <Window.Resources>
     <Style TargetType="syncfusion:GridGroupSummaryCell" x:Key="customGroupSummary" BasedOn="{StaticResource SyncfusionGridGroupSummaryCellStyle}">
         <Setter Property="FontWeight" Value="SemiBold"/>
         <Setter Property="HorizontalAlignment" Value="Right" />
     </Style>
 </Window.Resources>

 <Application.Resources>
     <ResourceDictionary>
         <ResourceDictionary.MergedDictionaries>
             <ResourceDictionary Source="/Syncfusion.Themes.MaterialLight.WPF;component/SfDataGrid/SfDataGrid.xaml" />
         </ResourceDictionary.MergedDictionaries>
     </ResourceDictionary>
 </Application.Resources>






Regards,
Sweatha.B

Attachment: SfDataGrid_Demo4_8_1b272508.zip


DG David García March 14, 2025 02:34 PM UTC

Hello,

Thank you for the guide about how to properly reference the base style to override.

Is there a place where there is a reference to all the controls styles that can be overriden? The link provided at the end shows the main style for each control, but not more details about other parts of the control that can be styled.


Thanks once again.



SB Sweatha Bharathi Syncfusion Team March 17, 2025 01:49 PM UTC

Hi David García ,

We have reviewed your query. Currently, we do not have a reference that demonstrates all the overridden styles for WPF controls.
However, you can use the export option in our ThemeStudio to generate a theme project for all WPF controls, which will allow you to customize the styles. 
 You can access the style for further customization. For more details, please refer to the following link:



Regards,
Sweatha.B

Loader.
Up arrow icon