9 Differences Between WPF And Windows Forms

Share this

August 27, 2014

WPF VS Windows Forms


About C#, Windows Forms & WPF


I have to admit that my interest in programming has “changed” lately. This doesn’t imply that I was bored with learning new programming techniques; actually, the opposite was true. The “change” means a shift towards a new programming language. As some of you might suspect from the introduction of the CodeEval post series, the new programming language that I am talking about is C#.

I can “hear” you asking: Does this decision implies no more VBA-related posts? Well, the answer is NO! I am using Office every day, and I have developed several custom functions/subs (many of which have not been published on this site), so I see no reason to leave behind VBA development – at least concerning Office applications. However, this site’s “programming side” may be enriched with some posts about C#

Sorry for this “irrelevant” introduction, but I think I had to explain why a post like this exists in this blog. In this post, I have summarized the key differences between Windows Presentation Foundation (WPF) – which provides developers with a unified programming model for building rich Windows smart client user experiences that incorporate UI, media, and documents – and the “old/classic” Windows Forms.

 


Differences


Windows Forms are built on User32 (older: User) and GDI+ (older: GDI) APIs, whereas WPF is built on DirectX API

  • DirectX can be used for games (motion), whereas User32 and GDI+ not. Why? Because User32 and GDI+ render via CPU, whereas DirectX renders via GPU (video card).
  • 3D graphics, motion, transparency of windows, etc., are some of the characteristics that can be built with WPF, contrary to the old grey-scale windows of Windows Forms.
  • WPF provides a more compelling user interface.
  • WPF and GPU hardware acceleration: on the newer windows Vista/7/8/10, more can be done than on XP.
  • WPF checks the machine’s hardware and software drivers that will be utilized to achieve optimal performance.
  • Old computer/less powerful system? No problem! WPF can use the CPU instead. Moreover, WPF can downgrade the motion, transparency, etc., to run in older computers (check RenderCapability.Tier, for example).

WPF uses XAML

  • XAML is built on top of the WPF API.
  • XAML is an XML type of language and is a familiar paradigm for graphic designers.
  • XAML tools: Expression Blend (from 2012, part of VS). It generates XAML and can open a VS project. The project can be opened simultaneously on VS and Expression Blend.
  • On WPF, both the graphic designer (front end) and the classic C#/VB.NET developer (back end) can work separately but efficiently.
  • With the Expression Design, you can create Assets, which can be orchestrated (motion, etc.) in Expression Blend, and, finally, handle the various events in Visual Studio.

WPF provides a new navigational project type

  • Navigate back and forth, similar to a browser (difficult to be done in Windows Forms).

The layout of user interface elements

  • Windows Form controls have issues regarding a) dynamic loading, b) localization (i.e. different versions for different languages), and c) their ability to be adjustable for people with disabilities (i.e. magnification of the button font).
  • WPF’s default layout is flowing; WPF can reshape, resize and reposition controls relative to other controls (similar to HTML).
  • So, WPF provides a new way of thinking about layout control for Windows developers.

WPF can use both audio and video

  • In Windows Forms, the implementation of the audio/video was somehow an afterthought, whereas, on WPF, complete implementation of audio and video is feasible.

Windows Forms have no real notion of animation

  • In Windows Forms, you could use C++ and GDI+ or DirectX directly, use timer control, etc. The outcome is that with Windows Forms, the animation is quite difficult and clunky.
  • Animations in WPF feature Storyboards, like timelines.

Themes and skins

  • In Windows Forms, the colors, and, in general, the ability to create custom themes for your forms/buttons, etc., is quite difficult.
  • With WPF, you can scheme an application with the use of styles and templates.

Other differences

  • Video resolution independence.
  • Better control and usage of text styles.
  • New application deployment options.
  • The ability to create documents.
  • Better printing.
  • From WPF, you can create Silverlight applications.

Finally, WPF

  • It requires a lot more time to master (it’s a large API).
  • It needs more computing resources than Windows Forms, so in old PCs, there might be issues.
  • A professional graphic designer (for an aesthetically pleasing user interface) is probably required.
  • Users might not be ready to accept a different user interface (i.e. with different colors etc.).
  • There is less third party support (i.e. controls) than Win Forms.
  • It cannot run on Windows 98.

 


Conclusion


As a general conclusion, there is no tremendous difference in respect to functionality. WPF delivers similar functionality with Windows Forms but with more “style”. Usually, the application specifications will somehow drive you to the most appropriate platform. However, this decision might be difficult due to many remarkable GUI toolkits (DevExpress, Telerik, etc.), which work on both platforms.

Page last modified: April 13, 2021

Christos Samaras

Hi, I am Christos, a Mechanical Engineer by profession (Ph.D.) and a Software Developer by obsession (10+ years of experience)! I founded this site back in 2011 intending to provide solutions to various engineering and programming problems.

  • Hi Scott,

    Thank you for your comment, which gives me the opportunity to clarify some things written on the post.
    The answer to your question is that it depends on the application. If you have created a “very heavy” user interface (a lot of visual effects, movement etc.), then in older computers you might not have the best results in respect of performance. However, if the same application was built on Win Forms, then the performance “hit” would be even higher!

    On the other side, when we say “old computer” how old we mean? A computer 3 – 4 years old will not have the same issues compared with a computer bought 10 years ago. As the fourth bullet in #1 says: “WPF and GPU hardware acceleration: on newer windows Vista/7/8 more can be done than on XP”, implying indirectly computer age. Moreover, WPF was first introduced in .NET Framework 3.0 (late 2006), so, that means that at least the cutting-edge computers at that time (2006) could run WPF without serious problems. So, as a general suggestion I would say that if the business computers in which you are planning to install your application were bought after 2007 (being right now 7 – 8 years old), then will be probably capable to run your WPF application without serious problems. If their age is less than 3 – 4 years old, then even better!

    Best Regards,
    Christos

  • Thanks Christos. I hope you understand I wasn’t trying to be critical of your post. I tend to be somewhat leading edge but definitely not bleeding edge since a lot of my user base tends to be in limited budgets and have older hardware. I’m all for using WPF over Winforms but wanted to be sure I wasn’t being premature knowing all that old hardware is still out there “waiting in the bushes” for me 🙂

  • Thanks for summarizing the differences but I have a question about a contradiction in your pros and cons. The last bullet in #1 says, “Old computer? No problem” because WPF will use the CPU instead of GPU to allow it to work on older machines, but in the second bullet of your conclusion you say there may be issues on older computers. From experience older computers will always be an issue when using newer technology but what’s your opinion on WPF vs. Winforms on an average business desktop, i.e. 3 years old and not cutting edge?

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
    Add Content Block
    >