How to use DevExpress Themes/Skins in C#

By FoxLearn 11/18/2024 11:17:12 PM   11.46K
To use the DevExpress Skin Manager in a C# Windows Forms application, you need to follow a few steps to apply and customize the UI skin.

Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "SkinDemo" and then click OK

First, ensure you have DevExpress installed and configured in your project. You can do this through the NuGet Package Manager or by installing the DevExpress components directly via their installer. You can view How to download and install DevExpress

The Skin Manager is a feature in DevExpress that allows you to apply predefined or custom skins to your application for a more modern and consistent look.

Drag and drop a Combobox control from Visual Studio toolbox onto your form designer.

devexpress skin

You need to import the namespaces relevant to Skin Manager and themes

using DevExpress.Skins;

The Skin Manager is responsible for managing the application's appearance. You can set the skin globally using the UserLookAndFeel class.

Create a XtraForm, then add code to handle your form as shown below.

private void XtraForm1_Load(object sender, EventArgs e)
{
    SkinHelper.InitSkinPopupMenu(SkinsLink);
    //Add skin to combobox
    foreach (SkinContainer cn in SkinManager.Default.Skins)
    {
        cboSkins.Properties.Items.Add(cn.SkinName);
    }
}

private void cboSkins_SelectedIndexChanged(object sender, EventArgs e)
{
    //Set default look and feel
    DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(cboSkins.Text);
}

If you want to dynamically list the available skins, you can do so by using SkinManager.Default.Skins, then add to combobox control allow the user to change the skin during runtime.

Next, Open Program class, then change your code as shown below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SkinDemo
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            //Register skins
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.Skins.SkinManager.EnableFormSkins();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new XtraForm1());
        }
    }
}

DevExpress Skin Manager is an excellent tool for applying consistent and modern UI themes across your application. You can use it to either select one skin globally or allow users to switch between skins dynamically at runtime. It offers a flexible and simple way to improve your application's visual design.

VIDEO TUTORIAL