Yes, mobile is the future of client applications, cross-platform is cool, web applications are amazing; but out there in the real world, there are still a ton of people who work all day with a Windows PC, and businesses that want PC applications in order to get their work done.
So when a business comes to you and says, we want a new Windows application to do this or that, and presuming they do not care about mobile or Macs or access over the internet but just want something that runs on their internal network, what framework do you choose?
Let us even assume that they all run Windows 10 so that UWP (Universal Windows Platform) is a realistic option.
If you want to code in .NET (which is a great choice for a Windows-only application, and with the possibility of migrating code to cross-platform via Xamarin’s compiler later), then you have three obvious choices:
Windows Forms
This is the framework for Windows desktop applications that was introduced at the same time as .NET itself, back in 2002. Of course it has been revised many times since. There was a big update in 2006 with .NET 2.0. That said, Microsoft intended it to be replaced by Windows Presentation Foundation (WPF, see below), so it has not been a focus of attention. In 2014, High DPI support was improved, with .NET 4.5.2, reflecting the fact that this ancient framework is still widely used.
Windows Forms is a nice wrapper around the Windows API, and easy to use in that it uses essentially X Y layout. In other words, you can think of your form as a grid of pixels with the position of your controls determined at design time by its size and coordinates. This is great if you are designing and running on the same PC, but not so good when you deploy to other PCs with different display settings. It does kind-of scale if you follow certain rules, but successful scaling in a Windows Forms application is often difficult to achieve, so users may suffer chopped-off controls and text, or just ugly screens. Read this carefully if you use Windows Forms. And then read about High DPI support, which was improved again in .NET Framework 4.7.
If you are writing a database application, you can generate datasets by drag and drop from the Server Explorer in Visual Studio and bind them to controls. I am not a fan of this database framework, which quickly gets convoluted, but you do not have to use it. However the ability to bind list and grid controls to any kind of .NET collection is fantastically useful.
Why is Windows Forms still in use? It is partly legacy and the fact that it is easier to maintain and enhance an existing application than to start again. It is also because, scaling issues aside, Windows Forms is reliable, well supported by both built-in and third-party controls, and easy to learn.
Windows Presentation Foundation
This was Microsoft’s second go at a GUI framework for .NET and in many respects a great improvement. It was introduced with .NET Framework 3.0 in 2006, part of the Vista wave of technology. Unlike Windows Forms, it is based on the DirectX graphics API, so great for multimedia and special effects. Scaling is built-in and based on layout managers. The underlying presentation language is based on XAML, an XML language. As with Windows Forms, there is deep support for binding data to controls.
Why would you not always use WPF rather than Windows Forms? The main issue is that the time you save on figuring out scaling is more than consumed by the time you spend on design. WPF is a designer-centric framework. It will repay your efforts, but if you just want to slap a couple of grids and a few buttons on a form to get a working business application, Windows Forms remains tempting.
Universal Windows Platform
Both Windows Forms and WPF are old, and Microsoft is pointing developers towards its Universal Windows Platform (UWP) instead. UWP is an evolution of the new application platform introduced in Windows 8 in 2012. If WPF was all about scaling and multimedia, the Windows 8 modern app platform is about touch support and Store-based deployment. The application model was also service based, the idea being that your app consumes services published over the internet. Until the Windows 10 Fall Creators Update, you could not use the .NET SQLClient to connect directly to a SQL Server database (you can now). The app platform became UWP with the launch of Windows 10 in 2015. UWP can use XAML for layout design, but it is not compatible with WPF.
Personally I have mixed feelings about UWP. Unfortunately it has suffered from Microsoft’s ever-changing development strategy. The Windows 8 app platform made sense to me as a way of bringing Windows into the tablet era and enabling applications that were more secure and more easily deployed, even if it tended to result in applications that were blocky and ugly. Microsoft then changed its mind about full-screen touch applications and came up with the UWP for Windows 10, where applications again run in a window, but with a new selling point: you could run your application on Windows Phone as well as desktop. Then the company canned Windows Phone, before UWP had properly launched, in effect deleting the “Universal” part of the platform.
UWP still offers Store delivery and isolation from other applications, better for security and stability. However there are a few things against it. First, users require Windows 10. Second, like WPF it is a designer-centric platform and not so good for running up quick business applications. Third, UWP apps behave differently from standard desktop applications, sometimes not in a good way.
I was using Microsoft’s bundled Photos application recently. I work a lot with images so this often pops up, as the default image viewer on Windows 10. I was not stressing it, but it crashed which, as is typical for a UWP app, means it just disappeared without any message or warning.
UWP will be three years old this summer, but I am not convinced that the platform is quite there yet. I find it hard to think of UWP apps that I love. The apps I know best are the built-in ones, Mail, Photos, Groove Music, Calculator, and I do not love any of them. Paint 3D is amazing but not my thing.
At the same time I do see the merits of UWP versus traditional Windows application deployment. The existence of the Desktop Bridge (formerly Project Centennial) means you can get many of those benefits while still using WPF or Windows Forms.
Closing thoughts
Perhaps something like Power Apps will render this discussion irrelevant before long. There are also other options for the desktop, such as Xamarin Forms if you still want to use .NET, or Electron for using web technologies for desktop applications.
Still, while it may seem surprising, even in 2018 I can think of reasons why you might use any of the above frameworks, even Windows Forms, for a business app targeting Windows.
Windows Forms is still a very relevant decision for enterprise apps with requirements as you mention. In fact, given it hasn’t changed that much means it’s as stable as all get out, and many 3rd party components have overcome shortcomings like scaling and styling.
Given the demise of LightSwitch and the constant change of UWP, I think many developers are wary of locking into a Microsoft framework.
Others might also be interested in Dean Chalk’s recent post:
“Microsoft And The UWP For Enterprise Delusion”
https://deanchalk.com/microsoft-and-the-uwp-for-enterprise-delusion-f22fcbbe2757
And see the first, sympathetic comment at the end which is from Tim Sneath. Tim was at Microsoft for 15 years and worked on WPF and Silverlight. He recently left Microsoft to go to Google where he is part of the group working on the mobile, web-based Flutter SDK/platform.
I’m personally still struck by the wide embrace of, and success of web technology at Microsoft itself (in addition to the embrace by the MS Windows enterprise customer base).
If Microsoft itself chose Electron (built on JavaScript and NodeJS) for the highly regarded Visual-Studio-Code Editor/proto-IDE, it makes me question my continued investment in any of WPF, UWP or Xamarin skills.
And through it all, the VCL still works, eh?
Indeed! Tim, it might be a good article to write about non-MS alternatives on Windows, sometime?
Tim:
In my spare time I now run an open source project, https://www.chem4word.co.uk/ . This brings chemistry handling to Word documents. It is arguably the most complicated add-in that has ever been produce for Word. Because it’s running on the desktop version, we use WPF for rendering chemical structures. It’s blazingly fast, powerful and makes some otherwise horrible jobs quite easy.
So, we in the Chem4Word more than a little wary of Microsoft’s push towards UWP. I personally hate the ‘new; way of architecting fullscreen apps, and I don’t like theOffice 365 versions of Office. I also gather than UWP hase a very much stripped down graphics framework. No DrawingVisuals, for instance.
What is your experience?
Hi Clyde, looks like Microsoft agrees with you re WPF 🙂
“This is the preferred technology for Windows-based desktop applications that require UI complexity, styles customization, and graphics-intensive scenarios for the desktop.”
https://msdn.microsoft.com/en-us/library/windows/desktop/dn614993(v=vs.85).aspx
“Why would you not always use WPF rather than Windows Forms? The main issue is that the time you save on figuring out scaling is more than consumed by the time you spend on design.”
you could not be more wrong, I can’t stand people who talk sh!t about thing they have zero clue about, WPF is the choice of real pros, UWP for slurp de jour fools, Forms for the greybeards, end of story.
“even in 2018 I can think of reasons why you might use any of the above frameworks” maybe your more of a blogger or a CRUD bum, take a look at Autocad , a grand a seat/year, top pros use WPF whos paying anything for UWP apps? of non vertical LOB in forms, delusional blowfication, typical b ig m outh blogger
Leaving aside your discourteous language, the truth is that there are many different levels of professional development from high-end commercial software to dull but important line of business applications; there are more people doing the latter of course.
Tim
You’re being much too ideological! Not helpful.
For everyone’s information, a WPF form can be added into a WinForm app, and vice versa. So – best of both worlds – either way.
You do not explained what is not true in saying:
The main issue is that the time you save on figuring out scaling is more than consumed by the time you spend on design.”
It take same time to create simple gui in Forms as in WPF?
yeah sorry about the “discourteous” language but after watching many years of disinformation and outright sabotage by people shilling inferior tech form Mossy Scott B (who can’t code to save his life) declaring it dead in 2011 to the darkest day of the creepy lil monkey Sinofsky jumping up and down about HTML5 sprits in at the first (and still utterly useless) BUILD conference, Metro/RT/Store/UWP is now 8 years old versus 12 for WPF is age is totally meaningless, and with a background in Forms , I can say without a doubt that is absolutely no contest as far as ease of layout (If you know what your doing obviously) and SCALING!, UWP and forms have ZERO support for UI Scaling, scaling the whole UI is not what I’m talking about, only WPF can Scale UI on a small high DPI displays without scaling everything, it’s easy (if you know how) as for Pros, you right I should have said something like High end Pros like Autodesk, Wall street and large enterprise that make the kick ass non-trivial solutions, starting pay for WPF Dev is about 100$k US and there is a ton of demand around the globe, is the true for say a WP or RT/Metro Dev that listened to Ms Barnes in 2011, not so much, it’s cost people nothing to promote the latest sure to be the future ( after all Scott H 2M$ say it’s da future) but it can make all the difference to the unsuspecting young Dev, so yeah I tak huge offense to people saying WPF is old ,dead , limited, too hard, slow, when they are just making it up or basing it on there own limited experience, UWP is inferior and way you slice it,
for Native development
iOS :Swift and Xcode
Andriod :C++/Jave, Andriod Studio
Windows: WPF, VS2015.3 for now
if you don’t have the resources X-platform seems viable,
and then when you try it you quickly realize the compromises mean inferiority to native,
if you want to talk about mundane functional that’s fine , but don’t kid yourself or others, there has never been any world class killer Xplat app, PERIOD
a great way to prove it go look at a blogger like mr asp core .NET and look at the old post of stating how this and that is dead and this or that is the future, it’s cost that jackass nothing to give one piece of bad advise after the other , he will still be big man VP at M$ and you’ll be screwed.
sorry for the typos /offensive language, the Anti WPF nonsense bring out the rage, I’m far from exclusively WPF and have no problem with Java,C++ or Swift , but I always have to back down from what I can do with full framework WPF,WCF,MEF etc. it’s not even close.
From the technical perspective you are totally right.
The .net framework is a solid base, beyond the shiny component layer, to build your application framework for special demands that can be addressed in an excellent fashion based on a profound architecture invented by you.
Sadly you lost the floating point speed of C/C++.
People who can afford such an architecture can afford writhing everything in C/C++ almost from scratch, simply because using WPF starts to pay at this point. The power of WPF lies beyond the shiny world of the components found in the Visual Studio or provided by third-party vendors.
On the other hand a simpler solution to all this is the RDP protocol ;).
A customer who needs such software needs a supplier who is in the position and trustworthy enough to handle million dollar project volumes. Even if the project does not require such an amount the suppliers simply play in that league today.
Designing using the technology mix mentioned is about growing companies into levels where you can very quickly face competition from others who simply hold a banking license.
The young developer you mentioned will be better off educating him or herself in the area of computer graphics and parallel computing as well as compiler and designing programming languages and math totally independent from the technology.
— History of communication —
a) Winforms rules
b) WPF will replace Winforms and Winforms is dead.
b1) What about blurry fonts and Vista?
c) WPF and Silverlight are the next big things
d) Winforms reanimated in .net 4 (VS 2010)
d1) Withdrawing the C++ .net integration
d2) Lightswitch, amazing backend plus Silverlight as a front-end dead
e) XAML (C++ and Javascript) is the next big thing (
f) Windows will be for games
M$ is pretty comparable to the ministry of silly walks. If there would be an award granted on a yearly basis for ‘If you cannot convince your ECO System, simply confuse them’ Microsoft would be the winner for almost 3 decades, without even a single break.
d) killed WPF’s reputation in a sense of becoming the preferred choice on every developer’s desktop.
e) There is enough movement in the C/C++ world toward more modern. Math and floating point speed are strongly tied together.
What do you expect that people might think?
Experience concerning the application of technologies is pretty dependent on the whether or not you want to grow a company, the domain, the processes and standards you will finally have to follow, … as well as the existing infrastructure found from where you get the data you want to visualize in an interactive fashion.
sorry, not even close,
.net floating point speed , ROFL
did sinofsky and his tawtsquad try to undermine WPF, yep,
did it work, only on the dabblers wannabes, just take a look at all the high paying WPF jobs all over the world, the try to get a position in “compiler and designing programming languages and math totally independent from the technology.”,
and for F sake RDP, ever hear of WCF ? , I send transcode 4k video in .Net and send it over WCF in real with a few lines of code, and
killed WPF’s reputation?
only with the ignorant, and speaking of
ignorant, never mind don’t want to get discourteous again
After 25 years of using MS products, I’m very wary of any tech that is not yet fully established. Too many products have been mothballed over the years and the amount of time developers have to spend troubleshooting a technical issues with the entire MS stack seems staggering to me as the years pass. With all the various assemblies, versions, platforms, and applications now in the mix it is just damn daunting at times to find the perfect compliment of those items to deliver to a company that couldn’t care less about the tech, but is all over us about the functionality. We just can’t afford to give so much time to maintaining and troubleshooting the myriad of exceptions thrown in today’s applications. Of course, I’m working in a large enterprise with a network topology consisting of no less than 700 servers, with Win 7 and Win 10 clients across 6 states. Basically, I’m about to retire and that’s my light at the end of the tunnel.
Every year or so I pick up UWP and every year after an hour or two I put it back down. I understand why they did some things but there are a mountain of things that should be easy that are difficult or are impossible. In every programming language I’ve used from now to the dawn of 1985 I’ve been able to open a file and read it’s contents with a few lines of code.
Ask a new UWP programmer to open a CSV file at “C:\Temp\test.csv” (without a picker dialog) and then watch their brain explode while they have to dig through a mountain of documentation only to learn it’s next to impossible. “But it’s SECURITY!!!”. Ya, I get it, but this is a metaphor for why UWP hasn’t taken off.
but you never actually answered the question – which one should we use?
There are reasons for each of them. So it depends on your requirements. For example, quick app for your desktop: Windows forms. App with stylish user interface that scales nicely: WPF. At this point I’m not sure why you would use UWP, unless there is some special reason eg you want to run on HoloLens.
Tim
4 months ago I finished programming a Human Machine Interface in WinForms. Then I had to do a program for a very similar machine and I pushed hard to change to WPF. I hope I never have to go back. These were fairly complex applications with charts and reports, restful hardware communication and complex robot like processes. Just yesterday, 2 hours before a demo of the new WPF machine, I found out that the requirements for screen presentation of the data were all wrong and several screens would all have to be completely re-arranged. I did it in about 20 minutes, thank god for Dock Panels and Stack Panels and Grids and everything XAML. . Everything just lined itself up and the demo looked great. Data binding to controls also seems more natural in WPF allowing to design in some real flexibility (less hard coded processes) to how the machine operates. It’s WPF for me. Every time I look at UWP I can never figure out why I would want to use it.
I’m making desktop LOB applications for internal usage in corporation. We’ve switched to WPF. However it appeared that Winforms are just nicer for the people. So we’ll return back to Winforms. And classic theme in WPF is not alternative – it is far from “true” classic.
The main problem with WPF it’s the great amount of time that you need to do anything.
And of course it’s very difficult in relation with winforms.
With winforms you can do a full app in minutes and for wpf you need too more minutes just for (only) design the gui.
As a component maker, I’d say WPF and UWP are a nightmare and it takes MS afterthoughts/hacks to draw anything with performance. That’s may more complex and even then the performance is not near Winforms, VCL, ActiveX. WPF is not real windows (it’s a runtime on top of Windows) with no windows handles and WPF event bubbling is another bottleneck. Real Windows architecture is always the best for real Windows development, meaning Winforms, ActiveXs, MFC, VCLs, etc. But the choice does depend on the needs of the app, but if it all possible, target Winforms for the most productive and future proof solution. Too many choose WPF or UWP simply due to dis-information. For a real world example, download our canned demo that includes MFC, Winforms, and WPF variations of the same demo. http://www.gigasoft.com