Skip to content
Thomas Baker edited this page Apr 23, 2022 · 8 revisions

WinFormMarkup A Fluent UI Markup Language for WinForms

Overview

Modeled after Kotlin's TornadoFX builder syntax, and MAUI's Markup API, WinFormMarkup is a declarative language for building WinForms applications. No special designers or IDE features needed.

The entire builder syntax is based on extension methods. It will apply to any derived classes built on top of the base WinForms class hierarchy. And, can be easily extended for custom classes and method.

Quick Start

Program.cs

namespace HelloWorld;

internal static class Program
{
    [STAThread]
    private static void Main()
    {
        ApplicationConfiguration.Initialize();
        Application.Run(new MainWindow());
    }
}

MainWindow.cs

using WinFormMarkup.Extensions;

namespace HelloWorld;

public class MainWindow : Form
{
        this.Text("Hello World!")
            .MinimumSize(700,300)
            .StartPosition(FormStartPosition.CenterScreen)
            .MainMenuStrip(
                new ToolStripMenuItem("&File")
                    .DropDownItems(
                        new ToolStripMenuItem("E&xit")
                            .Keys(Keys.Alt | Keys.F4)
                            .Clicked(_ => Application.Exit())
                    ))
            .Controls(
                        new Label()
                            .Text("Hi There!")
                            .Dock(DockStyle.Fill)
                            .FontSize(24))
            .Show();
}
Clone this wiki locally