-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Thomas Baker edited this page Apr 23, 2022
·
8 revisions
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.
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();
}