How to define a custom style (using BasedOn) for basic controls? (using SfSkinManager))

Hi, 

I checked the forum questions, go through the help document. But I failed to define custom style by using BasedOn. 

Basically, this is what I want to do (as a simple example): 

<Style x:Key="{x:Type Button}" TargetType="{x:Type Button}" BasedOn="{StaticResource ?????}" >
        <Setter Property="Background" Value="Purple"/>
 </Style> 

The answers in the forum and help documents are not consistent in the convention I typed ???? above. 

I'm using the theme VisualStudio2015, set SfSkinManager.ApplyStylesOnApplication = true; in my MainWindow (the very top window) and set syncfusionskin:SfSkinManager.Theme="{syncfusionskin:SkinManagerExtension ThemeName=VisualStudio2015}" in MainWindow.xaml file.

Based on my readings I need to merged the below dictionary in some place  but failed to find the correct namespace:

<ResourceDictionary Source="/Syncfusion.Themes.VisualStudio2015.WPF;component/Button/Button.xaml"/>

So where I can find the source location for the Button style file.  Again, there is some inconsistency in the forum answers and help documents, tried all that I found related. I would be happy if you provide some general convention (or provide me a reference where I can locate the style files), because I do not want to ask the very same question for each base control, or for each Syncfusion native controls. 

Finally, does it matter where I merge it, (is it okey if I merge in App.xaml - or do I have to merge in MainWindow.xaml)

Thank you in advance.



3 Replies

VR Vijayalakshmi Roopkumar Syncfusion Team May 3, 2021 11:05 AM UTC

Hi Serdar 
 
Thank you for contacting Syncfusion Support. 
 
Please find the response for the below query: 
 
S.NO 
Query 
Response 
1. 
I checked the forum questions, go through the help document. But I failed to define custom style by using BasedOn.  
We have checked the reported requirement and understood that you want to override the VisualStudio2015 style for MS Button control. For this the respective the xaml path and Based On name , is shown in following code: 
 
Code:[App.xaml] 
 
 
<ResourceDictionary> 
<!--Resource dictionary to merge for MS control--> 
<ResourceDictionary.MergedDictionaries> 
<ResourceDictionary Source="/Syncfusion.Themes.VisualStudio2015.WPF;component/Tools/MS Control/MS Control.xaml" /> 
</ResourceDictionary.MergedDictionaries> 
</ResourceDictionary> 
 
 
 
MainWindow.xaml 
 
<Style 
x:Key="{x:Type Button}" 
BasedOn="{StaticResource DefaultButtonStyle}" 
TargetType="{x:Type Button}"> 
<Setter Property="Background" Value="Purple" /> 
</Style> 
 
 
 
 
 
2 
So where I can find the source location for the Button style file.  Again, there is some inconsistency in the forum answers and help documents, tried all that I found related. I would be happy if you provide some general convention (or provide me a reference where I can locate the style files), because I do not want to ask the very same question for each base control, or for each Syncfusion native control 
We have logged a UG report for this and we will improve it with necessary information. We will update you once it get published. 
3 
 
inally, does it matter where I merge it, (is it okey if I merge in App.xaml - or do I have to merge in MainWindow.xaml) 
 
You can merge it in App.xaml or MainWindow.xaml.  However while merging the resource dictionary in App.xaml, the style would apply for the whole application. Whereas on merging resource in MainWindow, the theme would apply in window level. 
 
 
Please try this solution and let us know if it is helpful. 
 
Regards 
Vijayalakshmi VR 



SP Serdar Pehlivanoglu May 7, 2021 01:40 AM UTC

Hi Vijayalakshmi,

Thank you for the response. This was helpful and worked. it would be great to update help documents. 

Can you also provide the namespace for syncfusion controls? 

In the help document it says: 
Source="/Syncfusion.Themes.VisualStudio2015.WPF;component/ButtonAdv/ButtonAdv.xaml"/>

but it is  not existing. 

In the help document it says to use