How to create a Metro Live Tiles in C#

By FoxLearn 10/5/2024 3:35:23 AM   11.53K
Creating Metro Live Tiles using the Metro Framework in C# involves a few key steps.

Below is a guide to help you create Live Tiles for a Windows application using the Metro UI style.

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

Next, Right click on your project select Manage NuGet Packages -> Search metro framework -> Install

install metro framework

Drag and drop the MetroTile control from the Visual Studio Toolbox onto your form designer, then design your metro form as shown below.

metro live title in c#

You need to add a timer control to your metro form, then modify your code to handle metro live title as shown below.

using System;
using System.Drawing;

namespace MetroLiveTile
{
    public partial class Form1 : MetroFramework.Forms.MetroForm
    {
        public Form1()
        {
            InitializeComponent();
        }

        //Change image, background
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (metroTile1.BackColor == Color.LightSkyBlue)
            {
                metroTile1.Text = "FoxLearn";
                metroTile1.BackColor = Color.ForestGreen;
                metroTile1.UseTileImage = false;
            }
            else
            {
                metroTile1.Text = "Skype";
                metroTile1.BackColor = Color.LightSkyBlue;
                metroTile1.UseTileImage = true;
                metroTile1.Refresh();
            }
            //
            if (metroTile7.BackColor == Color.DeepSkyBlue)
            {
                metroTile7.Text = "FoxLearn";
                metroTile7.BackColor = Color.Orange;
            }
            else
            {
                metroTile7.Text = "Skype";
                metroTile7.BackColor = Color.DeepSkyBlue;
                metroTile7.Refresh();
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //Start your timer
            timer1.Start();
        }
    }
}

VIDEO TUTORIAL