Set VisualStyle for Derived in SkinStorage

4 May 20211 minute to read

This page explains Set VisualStyle for Derived in SkinStorage and more details.

Set Visual Style for dynamically added Derived Controls in WPF SkinStorage (Classic)

Normally, a control added to an application will dynamically pick up the existing style using the SkinStorage. But when an user control derived from the existing control is added to an application, a style based on the Base class should be defined in the application.

The following code snippet explains the scenario where an user control of Button type is exposed here.

<Button x:Class="WpfApplication2.TestButton"
Height="300" Width="300" xmlns:theme="" theme:SkinStorage.VisualStyle="Blend">  
public partial class TestButton : Button
    public TestButton()

Styles based on the button style should be defined in the application as follows. You have to merge the corresponding Resource Dictionary when overriding the style in the application.

<ResourceDictionary Source="/Syncfusion.Shared.WPF;component/SkinManager/BlendStyle.xaml"/>
<Style TargetType="local:TestButton" BasedOn="{StaticResource BlendButtonStyle}">
<Setter Property="Background" Value="GoldenRod"/>

The output is displayed as shown below.

Set visual style dynamically for derived controls