Themes For Wpf Applications

Posted on -
  1. Wpf Application Class
  2. Wpf Material Design

ThemesSfSkinManager control helps to apply the built-in themes to the Syncfusion UI controls for WPF. Add Themes to the ApplicationSyncfusion UI controls for WPF supports various visual styles stated above.

Theme

The corresponding style resources are included with the specific theme assemblies. To apply Visual Studio style, use “Syncfusion.Themes.VisualStudio2013.Wpf”. Also, refer to the required theme assemblies with the project when needed. Apply Visual Style to ControlsAny built-in themes can applied to the required control by VisualStyle attached property of the SfSkinManager. Now, apply the value as VisualStudio2013 to the VisualStyle property of the SfSkinManager for the Docking Manager control. Apply themes at run timeApplied built-in themes can be changed at the runtime by the VisualStyle property.

Here, a ComboBox Control is used to switch various built-in themes that are referred in the assembly references. Metro Blend VisualStudio2013 Office2013White Office2013DarkGray Office2013LightGray Office2010Black Office2010Blue Office2010Silver.

Private Sub ComboBoxSelectionChanged ( ByVal sender As Object, ByVal e As SelectionChangedEventArgs ) SfSkinManager. SetVisualStyle ( Me, CType ( System. Parse ( GetType ( VisualStyles ),( TryCast (( TryCast ( sender, ComboBox )). SelectedItem, ComboBoxItem )). ToString ), VisualStyles )) End Sub MS Controls ThemesAll built-in assemblies have Style resources for MS controls, so whenever an application get its style through SfSkinManager, the Theme’s corresponding MS Control style merges with the applied controls resource dictionary. Applying theme globally in the applicationBy Default SfSkinManager merges the required resource files from the Theme assembly to the applied control.

Wpf Application Class

Wpf

Wpf Material Design

Wpf xaml themes

To apply the theme globally in the application, set the ApplyStylesOnApplication property to True. It merges all the resource files to the Application’s Resource Dictionary. Public Class DockingAdv Inherits DockingManager Public Sub New SetResourceReference ( StyleProperty, GetType ( DockingManager )) End Sub End Class Clearing instance while using themes in applicationSfSkinManager will hold some instance to use it further while applying theme. But this can be cleared using the function named “Dispose(object)” which needs to be hooked in the place where you need to clear the theme applied from SfSkinManager as like below code. Here “object” refers to the element which instance needs to be cleared.