post-thumb

Is WinForms Dead?

Looking at the Established Choice vs. the New UIs

Windows Forms or WinForms has been around since the beginning of .NET (and before that with VB6) so the question makes sense. We have WPF and UWP now so why would we ever create a WinForm project? It seems like WinForms is only for legacy support. That all sounds logical, however, it is just not true. Microsoft has maintained and improved WinForms (including moving the back-end code to .NET 6 for better performance and compatibility). Their commitment to WinForms has remained steady. The reason for this is because WinForms fills a need that the other user interfaces do not: it is simple.

Look at WPF for a minute. If you create a new application, and you do it “right” (the way it was designed to be used), you will need to learn to use XAML. Then you need to start looking at binding. Then, to really do it right, you should consider MVVM (like I do here: [https://youtu.be/laPFq3Fhs8k]). Compare that to a WinForm app. Want to use drag and drop for the controls? Sure, that was what it was designed for. Need to assign a value to a control? No problem. Just specify Control.Text = “” and you are all set. Can you do this in WPF? Absolutely. The difference is that WinForms were designed to be built this way. WPF was designed to permit this but as a compromise rather than a primary way of doing things.

Beyond this, though, I use WinForms when I want to teach a simple UI technique (even my C# Application from Start to Finish course falls in this category). I want to have as little UI “stuff” to explain as possible. That is where WinForms shines. No, I am not teaching the latest and greatest UI but that isn’t the point a lot of the time. The problem is people get caught up thinking that the UI is the code. They are two different things. If I am teaching C# code, the UI I choose is the simplest possible so it stays out of the way of the true topic.

Finally, and this is really important, there are a LOT of companies that use WinForms in production today. In fact, at a recent conference I was at with a large group of C# consultants. When the audience was polled on which desktop UIs their clients were using, the vast majority were WinForms, a small group was WPF, and almost no one was UWP. So if you plan on using C# at a place of employment, WinForms is still a HUGE deal.

comments powered by Disqus