Nightmare using SfSkinManager and style a grid cell

I'm using Syncfusion WPF version 20.1.0.48 from NuGet

I have been trying to use SfSkinManager and SfDataGrid for two days, using 

syncfusionskin:SfSkinManager.Theme="{syncfusionskin:SkinManagerExtension ThemeName=Office2019Black}"

in any of my windows I have many many rendering problems of some components, at the end I find that I have to use SfSkinManager.ApplyStylesOnApplication = true before InitializeComponent() in the main window and now all is rendered correctly.

In a second step I want to apply a style to a cell of a SfDataGrid with the following code that is perfectly correct

<syncfusion:GridTextColumn.CellStyle>

<Style TargetType="syncfusiondg:GridCell">

<Setter Property="FontFamily" Value="Consola" />

<Setter Property="FontSize" Value="34" />

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

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

</Style>

</syncfusion:GridTextColumn.CellStyle>

but no luck, at the and I find that removing SfSkinManager all It is working correctly but I cant use a theme.

Is it possible that using Syncfusion theme is so difficult ? Ho Can I resolve the problem of styling a cell and continue to use  SfSkinManager ? 


Regards


6 Replies

SA Sulthan Amanu Syncfusion Team April 15, 2022 02:13 PM UTC

Hi GMG,

Your requirement can be achieved by define the Basedon property bound with SyncfusionGridCellStyle as StaticResource defined in GridCell Style of SfDataGrid. Please refer the below code snippet,

<Window.Resources>

<ResourceDictionary>

        <ResourceDictionary.MergedDictionaries>

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

        </ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

</Window.Resources>

<
syncfusion:GridTextColumn MappingName="CustomerID" HeaderText="Customer ID">

<syncfusion:GridTextColumn.CellStyle>

        <Style TargetType="syncfusion:GridCell" BasedOn="{StaticResource SyncfusionGridCellStyle}"

            <Setter Property="FontFamily" Value="Consola" />

            <Setter Property="FontSize" Value="34" />

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

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

        </Style>

</syncfusion:GridTextColumn.CellStyle>

</syncfusion:GridTextColumn>


We have prepared sample based on your requirement. Please check this and revert us if you need further assistance for this.

Regards,

Sulthan Amnau


Attachment: SfDataGrid_Demo_58e61999_9358989e.zip


GM GMG April 15, 2022 03:53 PM UTC

Hi, thanks for the reply, I tried and it works fine, but there is another problem, changing the theme at runtime the grid always remains with the old theme even if the application updates. I think the problem is the static resource 


<ResourceDictionary.MergedDictionaries>

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

 </ResourceDictionary.MergedDictionaries>


How can avoid this problem?


Best regards



GM GMG April 15, 2022 08:17 PM UTC

Also, how to make buttons and textbox to have rounded corners? When I apply the theme all components changes their corners to squared.


Beat regards



SA Sulthan Amanu Syncfusion Team April 19, 2022 06:26 PM UTC

Hi GMG,


We are still checking this reported query and have also forwarded it to our internal team to check on this. We will update you with further details on April 20, 2022.


Regards,

Sulthan Amanu



SA Sulthan Amanu Syncfusion Team April 20, 2022 06:04 PM UTC

Hi GMG,


Regarding this "changing the theme at runtime the grid always remains with the old theme" still we need to check some scenarios. we will check and update this on April 21, 2022.


Regards,

Dhanasekar M.



SA Sulthan Amanu Syncfusion Team April 21, 2022 06:39 PM UTC

Hi GMG,

You can achieve your requirement using the below code snippet,

C#:

private void ComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)

{

if (!this.comboBox.IsLoaded)

return;

if (e.AddedItems != null)

    {

var selItem = (e.AddedItems[0] as ComboBoxItem).Content;

this.dataGrid.Resources.MergedDictionaries.Clear();

this.dataGrid.Resources.Clear();

this.dataGrid.Resources.MergedDictionaries.Add(new ResourceDictionary()

        {

            Source = new Uri("/Syncfusion.Themes." + selItem.ToString() + ".WPF;component/SfDataGrid/SfDataGrid.xaml", UriKind.RelativeOrAbsolute),

        });

 

        SfSkinManager.SetTheme(this, new Theme() { ThemeName = selItem.ToString() });

    }

}


We have modified the sample based on your requirement. Please check this and revert us if you need further assistance.


Regards,

Sulthan Amanu


Attachment: SfDataGrid_Demo_6180a46f_bff2b391.zip

Loader.
Up arrow icon