Create Beautiful Themes for Syncfusion WPF Controls in 5 Minutes | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (174).NET Core  (29).NET MAUI  (207)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (40)Black Friday Deal  (1)Blazor  (215)BoldSign  (14)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (66)Flutter  (133)JavaScript  (221)Microsoft  (118)PDF  (81)Python  (1)React  (100)Streamlit  (1)Succinctly series  (131)Syncfusion  (914)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (36)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (147)Chart  (131)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (628)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (40)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (507)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (592)What's new  (332)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Create Beautiful Themes for Syncfusion WPF Controls in 5 Minutes

Create Beautiful Themes for Syncfusion WPF Controls in 5 Minutes

The WPF skin manager feature helps you apply themes for both Syncfusion and framework controls. There are 22 built-in themes that can be applied using SfSkinManager for rich user interface experiences. Some of the built-in themes’ color derivations can be customized using Theme Studio.

With the 2020 Volume 3 release, you can customize the colors, fonts, and font families in WPF themes even at the application level via code using the skin manager.

Let’s customize a WPF theme at the application level without using Theme Studio.

Customize WPF themes

The following steps show you how to customize the themes at the application level using the skin manager:

Step 1: Create a sample application.

Create a new WPF project or use an existing application. Here, we have created a WPF application with the DataGrid control.

Refer to the following code example.

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:syncfusion="http://schemas.syncfusion.com/wpf" 
        x:Class="WpfApplication1.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <syncfusion:SfDataGrid  x:Name="dataGrid"/>
    </Grid>
</Window>

Step 2: Create and register custom theme settings.

Next, register the theme settings before setting a theme for a window or control. Each theme supported in Theme Studio has a theme settings class with the theme name as the prefix. For example, if MaterialDark is the theme name, then there will be a theme settings class named MaterialDarkThemeSettings. For a complete list of theme settings, please refer to this link.

  1. Initialize the MaterialDarkThemeSettings class and change the color and font properties available in that class as needed.
    public partial class MainWindow : ChromelessWindow
     {
       public MainWindow()
         {
            MaterialDarkThemeSettings themeSettings = new MaterialDarkThemeSettings();
            themeSettings.PrimaryBackground = new SolidColorBrush(Colors.Red);
            themeSettings.PrimaryForeground = new SolidColorBrush(Colors.AntiqueWhite);
            themeSettings.BodyFontSize = 15;
            themeSettings.HeaderFontSize = 18;
            themeSettings.SubHeaderFontSize = 17;
            themeSettings.TitleFontSize = 17;
            themeSettings.SubTitleFontSize = 16;
            themeSettings.FontFamily = new FontFamily("Callibri");
            InitializeComponent();            
          }        
      }
  2. Next, register theme settings in the skin manager using the RegisterThemeSettings method, which accepts two parameters: theme name and theme settings instance.
    public partial class MainWindow : ChromelessWindow
     {
       public MainWindow()
          {
             MaterialDarkThemeSettings themeSettings = new MaterialDarkThemeSettings();
             themeSettings.PrimaryBackground = new SolidColorBrush(Colors.Red);
             themeSettings.PrimaryForeground = new SolidColorBrush(Colors.AntiqueWhite);
             themeSettings.BodyFontSize = 15;
             themeSettings.HeaderFontSize = 18;
             themeSettings.SubHeaderFontSize = 17;
             themeSettings.TitleFontSize = 17;
             themeSettings.SubTitleFontSize = 16;
             themeSettings.FontFamily = new FontFamily("Callibri");
             SfSkinManager.RegisterThemeSettings("MaterialDark", themeSettings);
             InitializeComponent();            
          }        
     }

Step 3: Set the theme to your application.

Then, set the required theme to the created project for which the custom theme settings is registered.

public partial class MainWindow : ChromelessWindow
  {
    public MainWindow()
      {
         MaterialDarkThemeSettings materialDarkThemeSettings = new MaterialDarkThemeSettings();
         materialDarkThemeSettings.PrimaryBackground = new SolidColorBrush(Colors.Red);
         materialDarkThemeSettings.PrimaryForeground = new SolidColorBrush(Colors.AntiqueWhite);
         materialDarkThemeSettings.BodyFontSize = 15;
         materialDarkThemeSettings.HeaderFontSize = 18;
         materialDarkThemeSettings.SubHeaderFontSize = 17;
         materialDarkThemeSettings.TitleFontSize = 17;
         materialDarkThemeSettings.SubTitleFontSize = 16;
         materialDarkThemeSettings.FontFamily = new FontFamily("Callibri");
         SfSkinManager.RegisterThemeSettings("MaterialDark", materialDarkThemeSettings);
         SfSkinManager.SetTheme(this, new Theme("MaterialDark"));
         InitializeComponent();            
      }        
  }

After executing these steps, we will get an output with a customized theme like in the following screenshot.
Output

References

Documentation link: https://help.syncfusion.com/wpf/themes/skin-manager

Demo link: https://github.com/SyncfusionExamples/customize-themes-using-theme-settings

Conclusion

I hope you now have a clear idea about customizing WPF theme colors and fonts at the application level using the skin manager. This feature will definitely save you time in achieving the customizations you require. You can download it in our 2020 Volume 3 release. You can check out all the new features in our release notes and on the What’s New page.

Now you can use the WPF skin manager and present your application with elegant and customized themes!

If you are not yet a Syncfusion customer, you can try our 30-day free trial to check out our available features.

If you wish to send us feedback or ask any questions, please use the comments section below. You can also contact us through our support forumDirect-Trac, or feedback portal. We are always happy to assist you!

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed