Class SfSkinManager
Represents the class that manages themes for Syncfusion controls.
Inheritance
Namespace: Syncfusion.SfSkinManager
Assembly: Syncfusion.SfSkinManager.WPF.dll
Syntax
public static class SfSkinManager : Object
Remarks
The Skin manager applies theme to all the controls in application in optimistic way. It iterates through controls in visual tree and add the corresponding theme resource dictionary to apply theme.
For example, if you are applying MaterialLight theme, skin manager will load resources from "Syncfusion.Themes.MaterialLight.WPF.dll". Ensure you have added theme assembly as reference.
It is recommended to apply theme before InitializeComponent for better performance.
The touch UI for particular control can be enabled using
Fields
SizeModeProperty
Identifies the SizeModeProperty dependency attached property.
Declaration
public static readonly DependencyProperty SizeModeProperty
Field Value
Type | Description | ||||||
---|---|---|---|---|---|---|---|
System.Windows.DependencyProperty | One of the SizeMode enumeration that specifies the size mode to be applied for control. The default value is Default. Fields:
|
Remarks
The identifier for the SizeModeProperty dependency attached property.
ThemeProperty
Identifies the Theme dependency attached property to get or set a theme name where SfSkinManager will utilize to apply themes for control and its child element in application.
Declaration
public static readonly DependencyProperty ThemeProperty
Field Value
Type | Description |
---|---|
System.Windows.DependencyProperty | The Theme theme info. The default value is instance of Theme with ThemeName property value as Default. |
Remarks
We can provide theme name in this format: MaterialDark and we can also provide custom theme name in this format: CustomTheme1;BaseThemeName where CustomTheme1 denotes the custom theme name and BaseThemeName denotes the theme name from which it is derived. For example CustomTheme1;MaterialDark.
Properties
ApplyStylesOnApplication
Gets or sets whether to maintain theme resources in System.Windows.Application.Resources or resources of root element to which Syncfusion.SfSkinManager.SfSkinManager.VisualStyleProperty attached property set.
Declaration
public static bool ApplyStylesOnApplication { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | true, if you want to maintain theme resource in System.Windows.Application.Resources. false, the theme resources will be maintained in the System.Windows.FrameworkElement.Resources of root elelemt to which Syncfusion.SfSkinManager.SfSkinManager.VisualStyleProperty attached property set. |
Remarks
It is not recommended to change ApplyStylesOnApplication at runtime. Also, ensure to set ApplyStylesOnApplication before setting Syncfusion.SfSkinManager.SfSkinManager.VisualStyleProperty property.
Methods
GetSizeMode(DependencyObject)
Gets the
Declaration
public static SizeMode GetSizeMode(DependencyObject obj)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | obj | Control for which SizeMode value is updated |
Returns
Type | Description | ||||||
---|---|---|---|---|---|---|---|
SizeMode | One of the SizeMode enumeration that specifies the size mode to be applied for control. The default value is Default. Fields:
|
Remarks
The touch compatible sizing will be configured using proper minimum height, minimum width, padding and margin etc. set for control to assist in touch interactions.
GetTheme(DependencyObject)
Gets the Theme value of particular control where SfSkinManager will utilize to apply respective themes for control and its child element in application.
Declaration
public static Theme GetTheme(DependencyObject obj)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | obj | The element to which the Theme must be set. |
Returns
Type | Description |
---|---|
Theme | The Theme theme info. The default value is instance of Theme with ThemeName property value as Default. |
Remarks
We can provide theme name in this format: MaterialDark and we can also provide custom theme name in this format: CustomTheme1;BaseThemeName where CustomTheme1 denotes the custom theme name and BaseThemeName denotes the theme name from which it is derived. For example CustomTheme1;MaterialDark.
RegisterThemeSettings(String, IThemeSetting)
Helper method to register theme name, Syncfusion.SfSkinManager.SkinHelper and its custom Syncfusion.SfSkinManager.IThemeSetting information.
Declaration
public static void RegisterThemeSettings(string themeName, IThemeSetting themeSetting)
Parameters
Type | Name | Description |
---|---|---|
System.String | themeName | Theme name (visual style) |
Syncfusion.SfSkinManager.IThemeSetting | themeSetting | Instance of Syncfusion.SfSkinManager.IThemeSetting in theme assembly |
Remarks
The Syncfusion.SfSkinManager.SkinHelper returns theme resource dictionary details to skin manager to apply theme. Supported themes and its settings
Examples
This example shows how to register theme name, Syncfusion.SfSkinManager.SkinHelper and its custom Syncfusion.SfSkinManager.IThemeSetting information.
using Syncfusion.Windows.Shared;
using Syncfusion.SfSkinManager
MaterialDarkThemeSettings materialDarkThemeSettings = new MaterialDarkThemeSettings();
materialDarkThemeSettings.PrimaryBackground = new SolidColorBrush(Colors.Red);
materialDarkThemeSettings.PrimaryForeground = new SolidColorBrush(Colors.Yellow);
materialDarkThemeSettings.FontFamily = new FontFamily("Arial");
materialDarkThemeSettings.BodyFontSize = 12;
materialDarkThemeSettings.SubTitleFontSize = 14;
string style = "MaterialDark";
SfSkinManager.RegisterThemeSettings("MaterialDark", materialDarkThemeSettings);
MenuAdv menuAdv = new MenuAdv();
SfSkinManager.SetTheme(menuAdv, new Theme() { ThemeName = "MaterialDark" });
SetSizeMode(DependencyObject, SizeMode)
Sets the
Declaration
public static void SetSizeMode(DependencyObject obj, SizeMode value)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | obj | Control for which SizeMode value is updated |
SizeMode | value | The SizeMode value |
Remarks
The touch compatible sizing will be configured using proper minimum height, minimum width, padding and margin etc. set for control to assist in touch interactions.
Examples
<syncfusion:MenuAdv x:Name="menuAdv" syncfusion:SfSkinManager.SizeMode="Touch"/>
See Also
SetTheme(DependencyObject, Theme)
Sets the Theme value to particular control where SfSkinManager will utilize to apply respective themes for control and its child element in application.
Declaration
public static void SetTheme(DependencyObject obj, Theme value)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | obj | The element to which the Theme must be set. |
Theme | value | The Theme SkinManager theme info. |
Remarks
We can provide theme name in this format: MaterialDark and we can also provide custom theme name in this format: CustomTheme1;BaseThemeName where CustomTheme1 denotes the custom theme name and BaseThemeName denotes the theme name from which it is derived. For example CustomTheme1;MaterialDark.
Examples
This example shows how to set default supported themes using Theme.
<syncfusion:MenuAdv x:Name="menuAdv" syncfusion:SfSkinManager.Theme="{syncfusion:SkinManagerExtension ThemeName=MaterialDark}"/>
using Syncfusion.Windows.Shared;
using Syncfusion.SfSkinManager
MenuAdv menuAdv = new MenuAdv();
SfSkinManager.SetTheme(menuAdv, new Theme("MaterialDark"));
This example shows how to set custom theme name using Theme.
<syncfusion:MenuAdv x:Name="menuAdv" syncfusion:SfSkinManager.Theme="{syncfusion:SkinManagerExtension ThemeName=CustomTheme1;MaterialDark}"/>
using Syncfusion.Windows.Shared;
using Syncfusion.SfSkinManager
MenuAdv menu = new MenuAdv();
SfSkinManager.SetTheme(menu, new Theme("CustomTheme1;MaterialDark"));