Hi all,
I'm setting up dynamic theme switching in a WPF app using SfSkinManager.ApplicationTheme and SfSkinManager.ApplyThemeAsDefaultStyle = true, switching between Windows11Light and Windows11Dark. This works great in my sample app — the themes apply correctly and controls update as expected.
Now I’d like to go a step further:
SfDataGrid so I don’t have to set 7–8 properties on every instanceTextBox controls (e.g., 300px) using a styleNormally I’d use BasedOn="{StaticResource {x:Type SfDataGrid}}" or similar, but I’m not sure how this plays with SfSkinManager. If I merge the theme resource dictionary manually to access the base style, it seems to conflict with the dynamic theming — i.e. it pulls in the rest of the theme with it, breaking the application theme for those components.
So my question is:
👉 What’s the correct way to define a BasedOn style that works with SfSkinManager and supports dynamic theme switching?
Any guidance or best practices would be hugely appreciated!
Thanks in advance.
Hi Dave,
Thank you for reaching out and sharing details with us,
Query: What’s the correct way to define a BasedOn style that works with SfSkinManager and supports dynamic theme switching?
We have checked the reported query from our end, and you are trying to apply the custom style using BasedOn. Now, we noticed that you are using the "SfSkinManager.ApplyThemeAsDefaultStyle = true" property as true. In SfSkinManager, once you enable this property as true, you do not need to add the BasedOn for the customized style. In your application, you can use the customized style, and the style will apply to your application controls. You can also refer to our documentation WPF Skin Manager | Apply Themes for Syncfusion WPF controls
If you still face the issue, please share the details with a replicate sample or video. It will help us assist you earlier.
Regards,
Sudharsan
Hi Sudharsan,
Oh, so simple in the end!
Yes, it’s working perfectly now — turns out I had a stray resource dictionary merged somewhere that was interfering with things. A quick note in the documentation might be helpful here, as many forum posts suggest manually merging the theme dictionaries, which led me down the wrong path (something along the lines of not needing to use BasedOn, or similar). Also, it’s worth highlighting that changing ApplicationTheme at runtime automatically swaps everything out — that’s powerful behaviour and definitely deserves a mention!
Just one small follow-up: in the Visual Studio XAML previewer, custom-styled controls appear to be based on the default Windows style rather than the Syncfusion theme, even though everything works correctly at runtime. Is there any way to improve preview accuracy? It’s only a minor niggle, but the last little thing I’d like to solve.
Kind regards,
Dave Taylor
Hi Sudharsan,
Just wanted to share a quick update - I've got the design-time styling working nicely in the Xaml previewer using the following pattern in my merged dictionaries:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d">
<d:ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Syncfusion.Themes.Windows11Light.WPF;component/MSControl/Button.xaml" />
</d:ResourceDictionary.MergedDictionaries>
<Button x:Key="MyButtonStyle" TargetType="Button" d:BasedOn={StaticResource WPFButtonStyle">
<Setter Property="Background" Value="Green" />
</Button>
</ResourceDictionary>
Hopefully this helps someone else in future (unless you guys have a better way that I'm missing)!
Kind regards,
Dave Taylor
Hi Dave,
Thanks for the suggestion,
We are glad that the provided response meets your requirement. Please let us know if you need further assistance. As always, we are happy to help you out.
Regards,
Sudharsan