Windows Presentation Foundation vs WinForms

DevToolsGuy / Friday, April 17, 2015

For a long time we’ve been using WinForms when it comes to building Desktop applications. WinForms provides access to the native Microsoft Windows interface elements by wrapping the existing Windows API in managed code. WPF on the other hand, is the new platform for Microsoft Windows application development, based on the .NET Framework. This framework provides a clear, object-oriented, extensible set of classes that enable you to develop rich Windows applications.

Microsoft Windows Presentation Foundation (WPF) is a user interface (UI) framework for building Windows client applications with immersive and intuitive user experiences. It is a subset of the Microsoft .NET Framework and was first introduced by Microsoft as part of .NET 3.0. It combines the application UI, 2D graphics, 3D graphics, documents, and multimedia into a single framework to help developers create rich and interactive applications.

WinForms

WinForms applications have always been used to develop desktop applications where you want the entire processing burden to be rested on the client machine. This includes everything from drawing of graphics applications to data-entry systems to point-of-sale systems and games.

Below are some of the pros & cons for using the WinForms when developing an application.

 

PROS

  • Extensive documentation can be found on the Internet
  • Plenty of examples and tested thoroughly for years
  • Supports WPF
  • There are lot of 3rd party controls in the market to make the job easier
  • The designer in Visual Studio is still, as of writing, better for WinForms than for WPF, where you will have to do more of the work yourself with WPF

 

CONS

  • Designing your own look and feel in an application is a lot of work
  • Extra cost incurred to buy third party controls

 

WPF

WPF is a next-generation presentation system for building Windows client applications with visually stunning user experiences. With WPF, you can create a wide range of standalone and browser-hosted applications. Although releases for WPF were stagnant for a while, Microsoft recently announced the future roadmap for WPF.

Below are some of the pros & cons of using WPF when developing applications:

PROS

  • Powerful styling and skinning structure
  • Easy to create an own look and feel
  • It’s very flexible so you can re design your own controls without buying new controls
  • It's newer and thereby more in tune with current standards of technology
  • Does support Windows Forms
  • XAML makes it easy to create and edit your GUI, and allows the work to be split between a designer (XAML) and a programmer
  • Highly advanced data binding possible.
  • Uses hardware acceleration for drawing the GUI, for better performance
  • The ability to reuse existing code
  • Declarative vs. procedural code

 

CONS

  • Requires .NET Framework 3.0
  • Compared to Windows Forms, still in evolving phases.
  • Requires Dx9 compatible video card for advanced graphics

 

 

When to use WPF & WinForms

It’s clear that both the technologies have pros and cons to be considered before developing an application. Most of the arguments around using the WPF focus on the fact that it lets you build a flashy User Interface which can easily be created with little effort. That said, WPF is not just for applications which require a bit of “eye candy”. Sure, WPF has a lot of support for visuals and animations. However, that’s not all it’s good for. 

WPF is an especially good platform to use if your applications involve various media types. For example, it’s great if you need to incorporate video, documents, 3D content or animated transitions between a sequence of images - or a combination of the above. WPF is also great if you need to create a skinned user interface, if you need to bind to XML data, dynamically load portions of a user interface from a Web service or want to create a desktop application with a Web-like navigation style.

WinForms definitely still has a role to play however. If you are building applications with no need for the extensive modern functionality in WPF, then there is no compelling reason to leave behind a time-tested, developer-approved platform.  WinForms certainly has more third party controls available, online resources, and developer communities than WPF currently does. It’s also much easier to find WinForms developers than WPF developers and WinForms currently has a much better design-time experience in Visual Studio than WPF. That fact alone is a very compelling reason to stick with WinForms.

WPF is the natural successor to WinForms…

In the end, choosing between WinForms and WPF depends on the application’s requirements. WPF is definitely the new kid on the block and WinForms might seem old and boring. Nonetheless, development choices depend on the situation and Microsoft is continuing to deliver and support WinForms so it won't be going away anytime soon.

So, should Windows developers drop WinForms and adopt WPF?

We say, why choose one when you can have the best of both? It’s always exciting to learn new things as a developer, especially techniques related to graphics, so WPF is a great tool to learn. Nonetheless, WinForms is dependable and remains incredibly powerful. Going forward there’ll continue to be support for both so learning more skills just adds another string to your bow.