Skip to content
Tom Baker edited this page Jun 12, 2021 · 8 revisions

Why WinForms?

Pick a UI, any UI

When WinForms functionality ported to .Net Core, it brought on a sense of nostalgia and piqued my interest in revisiting the UI from an earlier part of my career. But concerns tempered my sense of interest. There were so many other newer sexier UI’s out there, and coding without MVVM discipline these days seems silly. I remembered WinForms applications as plagued with spaghetti code, and the constant annoyance of figuring out how to work in the designer (or not work sometimes). The tight coupling with the designer also meant a tight IDE coupling. If your IDE didn’t have a designer, you were SOL.

Recently while getting ready to start a new project I did a survey of the current Windows UI ecosystem and IMHO it is currently a mess. If I were to start any desktop app right now in WPF or UAP, I would want to upgrade to at least WinUI 3 ASAP. UAP (with WinUI 2) would be closest to WinUI 3 but comes with all the sandboxed UAP constraints. WPF has a beautiful full-featured XAML and full desktop capabilities, but it isn’t WinUI 3 (yet).

The Good Ones Aren’t Ready For Prime-Time

The current preview of WinUI 3 is really not ready for primer time. And if I were going to code in WPF or UAP, or WinUI 3 (preview), why not just go to the ultimate target of MAUI? Or even Blazor desktop (as an alternative to Electron)? Then I would be cross-platform too. But, MAUI is even less ready for prime time. Although Xamarin had a cool fluent C# Markup syntax they were using for building UI’s that looked just like what I wanted. I am sure by the end of November 2021, this state will remedy itself.

Designer-Free And Fluent

I had been doing more Kotlin coding recently and saw that some of the newer features in C# seemed to be informed by innovations in other languages (like Kotlin). I had also seen the power of a DSL and type-safe builder pattern in Kotlin to make even ugly class systems useable (like TornadoFX did for JavaFX). Then I saw ReactiveUI gave WinForms some love too! So, I had a good MVVM framework, for less spaghetti code, and had seen the power of DSLs.

Good Enough For Now

WinForms has been around forever. It’s just chugged along, not raising a fuss. Sure, it may have been in maintenance mode until being open-sourced in 2018. And it’s kind of the homely step-child to the rest of the sexy newer UIs. But, WinForms just works and I can make an application today. Using .Net 5 I also get some of the cooler new C# features (ala Kotlin). If I could put a nice DSL wrapper around it, and use Reactive UI for MVVM, I would have something that was good enough. And has been good enough since 2002.

So, I’d started my new project, and I started building the UI with a DSL as I went along (just a bunch of extension methods really). When I realized they could be useful as a stand-alone library, I wanted to share the love... ❤

Thus, WinFormMarkup was born. Once the library gets to a sufficient level of completeness, and if there appears to be any interest in it, I intend to release a Nuget package. I’ve already added licensing, so it is usable now.

2021-06-12 bigtlb

Clone this wiki locally