How to use Winforms Modern UI Metro framework

Modern UI Metro framework brings the new Modern UI alias Metro UI of Windows 8 to .NET Windows Forms applications.

Supported platforms
  • Windows XP SP1/SP2/SP3 (without Aero Glass)
  • Windows Vista
  • Windows 7
  • Windows 8
  • Windows 10
Requirements
  • .NET Framework 2.0 and above.
 Installation:

Create a new Windows Forms application, then right click on the project and select Manage NuGet Packages...


Type metro framework in Search, select Metro - Modern UI Metro framework and click install



Now let's add Metro framaework to Toolbox, first right click on the project and choose rebuild. Then right click on Toolbox and choose Add tab and name it ' metro framework ':


Right click on this new tab and select Choose items:


Browse to "project folder\packages\MetroModernUI.1.4.0.0\lib\net" and select the three DLL files:



These are new items in the Toolbox:


Now right click on the Form and choose View Code then change Form1 code:

public partial class Form1 : MetroFramework.Forms.MetroForm


This is the new view of the Form:


Now let's drag MetroTile item to the Form, change its Text property to "Show Message Box":


Double click on MetroTile and add this code to show a MessageBox:

private void metroTile1_Click(object sender, EventArgs e)
{
    MetroFramework.MetroMessageBox.Show(this, "WARNING", "MESSAGE BOX", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}

Run the application, this is the output:


For more explanation check out this video:





How to use Winforms Modern UI Metro framework How to use Winforms Modern UI Metro framework Reviewed by Bloggeur DZ on 12:40 Rating: 5

5 commentaires:

  1. Hi! I have an issue using Metro Framework 1.4.0
    If I want to change the color of the items (both fore and backcolor) or the font style in a ListView, nothing happens. If I use the default ListView of .NET, the code works of course. What could be the problem?

    foreach (Requests req in myRequests)
    {
    ListViewItem item = new ListViewItem(req.Start.ToShortDateString());
    item.SubItems.Add(req.Days.ToString());
    item.SubItems.Add(req.Status.ToString());
    item.Font = new Font(item.Font, FontStyle.Regular);
    if (req.Status == 'D')
    {
    item.BackColor = Color.Red;
    item.Font = new Font(item.Font, FontStyle.Strikeout);
    }
    else if (req.Status == 'A')
    {
    item.BackColor = Color.LightGreen;
    }
    else item.Font = new Font(item.Font, FontStyle.Bold);
    lsvMyRequests.Items.Add(item);
    }

    RépondreSupprimer

Fourni par Blogger.