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.
- 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.
|
# 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>
|
Thirupathi B.
This was what I needed. Thank you.
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>
Die Ressource "buttonadv/buttonadv.xaml" kann nicht gefunden werden.
What happened?
Thank you for your help.
Regards,
Peter
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> |
Regards,
Sudharsan
Attachment: MetroThemeDemo_32320056.zip
- 5 Replies
- 4 Participants
-
CB Chris Bentley
- Oct 6, 2021 08:19 PM UTC
- Feb 22, 2024 07:51 AM UTC