We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

CellStyleSelector do not word properly when Fleunt theme is applied

With

        <Style TargetType="syncfusion:GridCell" x:Key="nullCellStyle" >
            <Setter Property="Background" Value="LightYellow"/>
            <Setter Property="Foreground" Value="Red"/>
        </Style>


we have

 

or


no foreground color is applied and something wrong goes with cell border..


Attachment: SyncfusionTests_31576bf7.zip


3 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team January 19, 2023 09:09 AM UTC

Hi Krzysztof,

The reported problem occurs due to defined the default style for GridCell. When applying the theme to SfDataGrid, we merged the FluentLight merge resource dictionary into the application. If you want to customize the cell style in SfDataGrid you should use the relevant key for the target type, which is used in MergedDictionary. If you didn't define the key, the default style merged, which is why you saw the default border instead of the applied theme.


However, you can avoid this by adding the ResourceDictionary based on the applied Theme (ex: FluentLight). BasedOn property bound with SyncfusionGridCellStyle as StaticResource in defined Style based. Refer to the below code snippet.

<Application.Resources>

     <ResourceDictionary>

         <ResourceDictionary.MergedDictionaries>

             <!--Here add the ResourceDictionary for the applied theme in your application-->

             <ResourceDictionary Source="/Syncfusion.Themes.FluentLight.WPF;component/SfDataGrid/SfDataGrid.xaml"/>

         </ResourceDictionary.MergedDictionaries>

 

         <!--Here add the BasedOn proeprty for override the theme style for GridCell-->

         <Style TargetType="syncfusion:GridCell" BasedOn="{StaticResource SyncfusionGridCellStyle}" x:Key="nullCellStyle" >

             <Setter Property="Background" Value="LightYellow"/>

             <Setter Property="Foreground" Value="Red"/>

         </Style>

     </ResourceDictionary>       

 </Application.Resources>


Find the modified sample in the attachment.


Regards,

Vijayarasan S


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.



Attachment: ModifiedSample_f0221694.zip

Marked as answer

KR Krzysztof January 19, 2023 11:06 AM UTC

thanks but what if i want to change theme at runtime ? 

doing that 

        <ResourceDictionary.MergedDictionaries>
            <!--Here add the ResourceDictionary for the applied theme in your application-->
                <ResourceDictionary Source="/Syncfusion.Themes.FluentLight.WPF;component/SfDataGrid/SfDataGrid.xaml"/>
                <ResourceDictionary Source="/Syncfusion.Themes.FluentDark.WPF;component/SfDataGrid/SfDataGrid.xaml"/>
            </ResourceDictionary.MergedDictionaries>



KR Krzysztof January 20, 2023 06:52 AM UTC

my message from 12:06 was not claer please ignore.

I really appreciate your help - thank you.


Loader.
Up arrow icon