Primary Button in .NET 8 Application

Hi,

I am a bit confused how to use the styles from the Theme Studio correctly. I have created my own theme based on the Windows 11 Light Theme. Under the framework controls point in the Theme Studio I see the “Primary Button”. If I have understood correctly, this is a standard button. How do I get my standard button to become a primary button?

I have registered my theme in App.xaml.cs: 

private static void RegisterTheme()
{
    const string style = "myThemeLight";
    const string skinHelperStr = "Syncfusion.Themes." + style + ".WPF." + style + "SkinHelper, Syncfusion.Themes." + style + ".WPF";
    var skinHelperType = Type.GetType(skinHelperStr);
    if (skinHelperType == null)
    {
        return;
    }


    if (Activator.CreateInstance(skinHelperType) is SkinHelper styleInstance)
    {
        SfSkinManager.RegisterTheme("myTheme", styleInstance);
        SfSkinManager.ApplyStylesOnApplication = true;
    }
}

And I added the theme in my window with the following code:

mlns:syncfusion="http://schemas.syncfusion.com/wpf" x:Class="TestApp.UI.MainWindow"
        xmlns:syncfusionSkin="clr-namespace:Syncfusion.SfSkinManager;assembly=Syncfusion.SfSkinManager.WPF"
        syncfusionSkin:SfSkinManager.Theme="{syncfusionSkin:SkinManagerExtension ThemeName=myTheme}"

But in the button control I didn't find a way to set the primary button style defined in the theme. What do I miss to use the style?

Kind regards,
Christian


3 Replies 1 reply marked as answer

SN Sudharsan Narayanan Syncfusion Team February 3, 2025 03:05 PM UTC

Hi Christian,

We have checked your reported query that "Set Style as PrimaryButton". We suggest setting the Primary Button style key for the Button as shown below,



You can also refer the style key from the below documentation,

WPF Skin Manager | Apply Themes for Syncfusion WPF controls


And, we have attached the sample below. If you are still facing the issue. Please share the modified sample with us. It will be helpful for us to prompt the solution.

Regards,
Sudharsan


Attachment: ButtonSample_2285ab54.zip

Marked as answer

CD Christian Deubel February 3, 2025 04:28 PM UTC

Thx a lot!

I had 2 problems in my code:

  1. I merged the wrong resouce dictionary in my app.xaml.
  2. I had additional styles in the app configuration and visual studio wanted me to name my merged dictionary. That's why it didn't find the style afterwards. I have now declared my styles in the merged dictionary and now everything works.
With your help, it works now :)


SN Sudharsan Narayanan Syncfusion Team replied to Christian Deubel February 4, 2025 06:59 AM UTC

Hi Christian Deubel,

We are glad that the provided response meets your requirement. Please let us know if you need further assistance. As always, we are happy to help you out.

Regards,
Sudharsan


Loader.
Up arrow icon