Applying a theme to Syncfusion controls and .NET framework controls

I'm trying to use both .NET controls and Syncfusion controls in the same window, and would like to apply the SystemTheme to all. I've added the references to SfSkinManager.WPF and SystemTheme.WPF.   

I've added the below to my window.

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

But, my .NET controls are not getting the style. For example, a <TextBox>.  Second to this, is it possible to derive a new style from the Syncfusion style (BasedOn="..."), if I wanted a <TextBox> to have all of the normal Syncfusion styling, but have a different Foreground.

Thank you.



5 Replies

TB Thirupathi Bala Krishnan Syncfusion Team October 7, 2021 01:07 PM UTC

Hi Chris,  
 
Thanks for contacting Syncfusion support. 
 
We have analyzed your reported query “How to apply SystemTheme to syncfusion controls and .net framework controls”. You can meet this requirement by doing the following code changes in your application.             
  • Add respective resource dictionary from the themes assembly to the application.
  • Define the new style using the BasedOn property.
  • Change the value of the foreground property in the derived style.
 
Please refer the following code sample. 
 
# MainWindow.xaml 
 
<Window 
        syncfusionskin:SfSkinManager.Theme="{syncfusionskin:SkinManager ThemeName=SystemTheme}”> 
    <Window.Resources> 
       <ResourceDictionary> 
            <ResourceDictionary.MergedDictionaries> 
                <ResourceDictionary Source="/Syncfusion.Themes.SystemTheme.WPF;component/MSControl/TextBox.xaml"/> 
                <ResourceDictionary Source="/Syncfusion.Themes.SystemTheme.WPF;component/ButtonAdv/ButtonAdv.xaml"/> 
            </ResourceDictionary.MergedDictionaries> 
        </ResourceDictionary> 
    </Window.Resources> 
    <Grid> 
        <Grid.Resources> 
            <Style TargetType="TextBox" BasedOn="{StaticResource WPFTextBoxStyle}"> 
                <Setter Property="Foreground" Value="Red"/> 
            </Style> 
 
            <Style TargetType="syncfusion:ButtonAdv" BasedOn="{StaticResource SyncfusionButtonAdvStyle}"> 
                <Setter Property="Foreground" Value="Red"/> 
            </Style> 
        </Grid.Resources> 
 
        <TextBox HorizontalAlignment="Left" Height="23" Margin="10" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="120"/> 
 
        <syncfusion:ButtonAdv Content="ButtonAdv" HorizontalAlignment="Left" Height="29" Label="Click" Margin="10" VerticalAlignment="Center" Width="97"/> 
    </Grid> 
</Window> 
 
 
Based on your specifications, we created a simple sample in which we used the TextBox (MS control) and ButtonAdv (Syncfusion) controls in the same window. 
 
 
For more details, please refer our UG documentation from the following link: 
 
Could you please try the above solution and let me know whether or not the stated scenario has been resolved? If you are still having problems, please share your control list from your actual application. We'll recommend the syncfusion style basedOn property based on this. 
 
Regards,
Thirupathi B.
 



CB Chris Bentley October 7, 2021 07:41 PM UTC

This was what I needed.  Thank you.



TB Thirupathi Bala Krishnan Syncfusion Team October 8, 2021 05:53 AM UTC

Hi Chris, 

Thanks for confirming that our solution meets your requirement. Please let us know if you need any further assistance on this. As always, we will be happy to assist you. 

Thirupathi B. 



PB Peter Bernhardt February 21, 2024 11:43 AM UTC

Hi,

I've tried to use your advice

           
<ResourceDictionary.MergedDictionaries>    
   <ResourceDictionary Source="/Syncfusion.Themes.Metro.WPF;component/ButtonAdv/ButtonAdv.xaml"/>
   <ResourceDictionary Source="/Syncfusion.Themes.Metro.WPF;component/MSControl/TextBox.xaml"/>
</ResourceDictionary.MergedDictionaries> 

But I keep getting a ressource not found error:

 Die Ressource "buttonadv/buttonadv.xaml" kann nicht gefunden werden.


What happened?


Thank you for your help.

Regards,

Peter



SN Sudharsan Narayanan Syncfusion Team February 22, 2024 07:51 AM UTC

Hi Peter,


We have checked your query, "Resource cannot found". We have prepared the sample with the correct source path for the Metro theme. Please find the sample for reference.

<ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Syncfusion.Themes.Metro.WPF;component/Tools/MS Control/MS control.xaml"/>
        <ResourceDictionary Source="/Syncfusion.Themes.Metro.WPF;component/Tools/ButtonAdv/ButtonAdv.xaml"/>
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

If we misunderstood the query, please modify our sample and revert to us with reproducible issue or video. So, it will be helpful to prompt the solution on further.

Regards,
Sudharsan

Attachment: MetroThemeDemo_32320056.zip

Loader.
Up arrow icon