Windows Forms: Modern UI Metro Framework Windows 8 UI in C#
By FoxLearn 7/15/2017 8:01:57 PM 8.02K
Design Flat Login Modern UI Metro Framework Windows 8 UI using Metro Framework, Metro theme, Metro style in C#
Step 1: Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "MetroUILogin" and then click OK
Step 2: Right click on your project select Manage NuGet Packages -> Search metro framework -> Install
If you don't see the metro framework in your toolbox, you can view How to download and install metro framework
Step 3: Design your form as below
Create metro user control
ucLogin
ucDashboard
Step 4: Add code to handle your winform as below
frmMain
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MetroUILogin { public partial class frmMain : MetroFramework.Forms.MetroForm { private static frmMain _instance; public static frmMain Instance { get { if (_instance == null) _instance = new frmMain(); return _instance; } } public MetroFramework.Controls.MetroPanel MetroContainer { get { return this.mPanel; } set { this.mPanel = value; } } public frmMain() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //Load login form ucLogin uc = new ucLogin(); uc.Dock = DockStyle.Fill; mPanel.Controls.Add(uc); _instance = this; } } }
ucLogin
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using MetroFramework.Controls; namespace MetroUILogin { public partial class ucLogin : MetroUserControl { public ucLogin() { InitializeComponent(); } private void btnLogin_Click(object sender, EventArgs e) { //Check login if (txtUsername.Text == "admin" && txtPassword.Text == "admin") { ucDashboard uc = new ucDashboard(); uc.Dock = DockStyle.Fill; frmMain.Instance.MetroContainer.Controls.Add(uc); frmMain.Instance.MetroContainer.Controls["ucDashboard"].BringToFront(); } } } }
ucDashboard
using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MetroUILogin { public partial class ucDashboard : MetroFramework.Controls.MetroUserControl { public ucDashboard() { InitializeComponent(); } } }
VIDEO TUTORIALS
- How to Create a Metro ListView in C#
- How to Create a Metro GridView in C#
- How to Create a Modern UI Login Form in C#
- How to Create a Metro TextBox in C#
- How to create a Metro Message Box in C#
- How to use Modern UI Metro Framework in C#
- How to Download and Install Metro Framework
- Windows Forms: How to use WinForms Modern UI Metro Framework in C#