How to use Modern UI Metro Framework in C#

By FoxLearn 12/12/2024 3:08:04 PM   9.36K
Designing a modern UI for a WinForms application using the Metro Framework is a straightforward process.

The Metro Framework is a popular library for creating modern and sleek UIs in Windows Forms applications.

How to use Modern UI Metro Framework in C#?

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

Right click on your project select Manage NuGet Packages -> Search for MetroFramework and install

install metro framework

Design your form as shown below.

Form1

metro ui c#

frmAddEditStudent

c# metro ui

Open your form, then modify the base class to MetroFramework.Forms.MetroForm

public partial class Form1 : MetroFramework.Forms.MetroForm
{
     //....
}

public partial class frmAddEditStudent : MetroFramework.Forms.MetroForm
{
     //....
}

You can add code to set the theme and style dynamically.

public Form1()
{
    InitializeComponent();

    this.Style = MetroFramework.MetroColorStyle.Blue; // Choose a style (e.g., Blue, Red, Green)
    this.Theme = MetroFramework.MetroThemeStyle.Dark; // Choose a theme (Dark or Light)
}

VIDEO TUTORIAL