Wednesday, 27 August 2014

WPF VS Windows Forms


I have to admit that in the last few months my interest about programming “changed”. This doesn’t imply that I was bored 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 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 (some of which have not been published in this blog), so I see no reason to leave behind VBA development – at least with respect to Office applications. However, it is quite possible that the “programming side” of this blog will be enriched with some posts about C#.

Sorry for this “irrelevant” introduction, but I think I had to explain to you why a post like this exists in this blog. So, 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.


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

2. WPF uses XAML:
  • XAML is built on the top of WPF API.
  • XAML is an XML type of language and is familiar paradigm for graphic designers.
  • XAML tools: Expression Blend (from 2012, part of VS). It generates XAML and can open a VS project. Actually a 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 then can be orchestrated (motion, etc.) in Expression Blend, and, finally, handle the various events in Visual Studio.

3. WPF provides new navigational project type:
  • Navigate back and forth, similar to a browser (difficult to be done in Windows Forms).

4. 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 flow; WPF can reshape, resize and reposition controls relative to other controls (similar to HTML).
  • So, WPF provides a new way of thinking about control layout for Windows developers.

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

6. Windows Forms have no real notion of animation:
  • In Windows Forms you could use C++ and GDI+ or DirectX directly, or user a timer control etc. The outcome is that with Windows Forms, animation is quite difficult and clunky.
  • Animations in WPF feature Storyboards, like time lines.

7. 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.

8. Other differences:
  • Video resolution independence.
  • A 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.

9. Finally, WPF:
  • Requires a lot more time to master (it’s a large API).
  • Needs more computing resources than Windows Forms, so in old PCs there might be issues.
  • A professional graphic designer (for an aesthetically pleasant 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.
  • Cannot run on Windows 98.


As a general conclusion, there is no tremendous difference in respect of 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, although this decision might be difficult due to the existence of many remarkable GUI toolkits (DevExpress, Telerik etc.), which work on both platforms.

Did you like this post? If yes, then share it with your friends. Thank you!


Mechanical Engineer (Ph.D. cand.), M.Sc. Cranfield University, Dipl.-Ing. Aristotle University, Thessaloniki - Greece.
Communication: e-mail, Facebook, Twitter, Google+ and Linkedin. More info