Depending on your age and experience as a .NET developer, you might or might not be familiar with the technology known as Windows Forms. Windows Forms, or WinForms, was introduced together with .NET 1.0 in 2002. It was the first desktop UI technology for .NET.
We’re now 16 (!) years later, and WinForms runs on the latest version of the .NET Framework (currently 4.7.2) and .NET Core (currently 2.1). But because it’s so old, has been succeeded by WPF and UWP, and only runs on Windows, many assume WinForms is dead.
And while it certainly has some wrinkles on its face, it’s not just dead yet.
Don’t believe me? Keep reading.
A Brief History of WinForms
As I mentioned, WinForms was introduced together with the first version of the .NET Framework in 2002.
Don’t underestimate how different these times were.
Download a free trial of CodeIt.Right and get instant, specific code reviews that help you get it right, whether you use Winforms, WPF, or anything else.
A Snapshot of the World When Winforms Was Born
The first iPod had only been released four months earlier, and Microsoft Windows was still the platform of choice for basically everybody. Speaking of Windows, Windows XP had also just been released.
The internet was already quite prevalent, depending on where you lived, but it wasn’t the internet we know now. Techniques like AJAX existed, but were very rare (in part because it would take another four years for jQuery to be released). The desktop was still where it all happened.
And the desktop, that was Windows.
WinForms provided .NET developers a familiar way of writing user interfaces, as WinForms was a layer above the Win32 API. You could write both the underlying code and the UI in the same .NET language, C# and VB.NET being the most popular ones.
The introduction of .NET also saw the release of an IDE: Visual Studio. Visual Studio included a drag-and-drop UI designer for WinForms. This greatly improved the productivity of developers, even if they weren’t UI experts.
WPF and the Aging of Winforms
WinForms received several improvements?in subsequent versions of the .NET Framework. But in 2006, Microsoft introduced .NET 3.0, which included the Windows Presentation Foundation or WPF. WPF took a different approach.
WPF separated the behavior of a user interface control from the way it looked. At the time, this was revolutionary and it gave us the possibility to do crazy things, even if they weren’t always very usable. WPF also brought us XAML, i.e. the Extensible Application Markup Language.
The combination of a .NET language (e.g. C# or VB.NET) for logic and XAML for markup continued in Windows 8 and Windows 10. The latest desktop UI framework from Microsoft, the Universal Windows Platform or UWP, is based on XAML.
So has Microsoft moved on after WinForms? After all, they have released several other desktop UI frameworks, and WinForms is a staggering 16 years old! The answer is more complex than just yes or no.
The Current State of WinForms
Because WinForms has been around for so long, it is a very mature platform that integrates into Windows very well. WinForms applications could be written years ago and still run fine on Windows 10.
Also, don?t underestimate how many companies still have WinForms applications that are important to their daily operations. You could do worse than to specialize in maintaining, improving or porting these applications.
Another important fact is that Microsoft hasn?t stopped support for WinForms. While there are no major new developments planned for WinForms, they will keep releasing bugfixes. These ?bugfixes? include things like improvements for high DPI monitors in .NET Framework 4.8.
.NET Framework 4.8 is the last version of the ?old? framework. But you will also be able to run your WinForms apps on .NET Core 3!
Even the next version of .NET, Version 5, will support WinForms, allowing you to use the new API?s that Microsoft will introduce as part of .NET 5.
This doesn?t sound like a platform that is completely dead.
Where WinForms Is Still Useful
You might think this situation is comparable with the many COBOL applications running out there. They are making money, in need of maintenance and updates, but not something for creating new applications.
But there is something WinForms does better than WPF or UWP: ease of development.
WinForms is great for making a quick prototype of an application. The learning curve is a lot less steep than it is for WPF or UWP.
The UI editor in Visual Studio is much better. No need to struggle with the often complex syntax of XAML, just drag and drop your controls and wire it up to your code.
For WinForms apps that run on .NET Core, the designer is currently missing for Visual Studio 2019, but there is a workaround. And the team is working on a real solution.
If you want to focus as little as possible on your UI code, WinForms is actually a better choice than WPF or UWP. WinForms allows you to focus on your business logic, and spend less time developing your UI.
But It’s Almost Dead, Right?
You never really know which direction the technology world is going to take. WinForms has been able to stay around for a very long time, longer than most web UI frameworks can dare to dream about.
I think we could even say that WinForms can still be relevant for desktop applications on the PC, it’s just that the PC desktop has lost a lot of its relevancy.
We might spend a lot of time working on our desktop, but we only use a handful of desktop applications: mainly office applications and a browser. And we spend most of our time in the browser.
I’m even writing this in a browser, instead of a desktop text editor. This sounds normal now, but it hasn’t always been so.
So if you’re starting a new app that will be around for a while, your best choices are probably Xamarin or the web. This depends on how familiar you are with these technologies, but they are currently the most future proof and they run on more than one platform.
But to say that WinForms is dead is a bridge too far. WinForms applications continue to run on thousands of PC’s, and these applications will need to be maintained and improved upon for the coming years.