开发者

Why should I use WPF over Winforms? Any examples of WPF outperforming Winforms?

There is a similar question at WPF versus Windows Forms which has some good information but in my personal experience I see no reason to use WPF over Winforms. With WPF initially there was lots of talk about it's multi-threaded functionality but in use I see no benefits.

I have two开发者_开发百科 applications that do the same thing, one in WPF and on in Winforms. The Winforms application blows the WPF application away in terms of performance (by a factor of 10) and looks just as nice.

Granted I am more proficient in Winforms applications than WPF.


There is another discussion on the subject here: When is Windows Forms the correct choice vs WPF?

The Winforms application blows the WPF application away in terms of performance (by a factor of 10) and looks just as nice.

WPF is about more than just fancy graphics... I'm not a designer, hell I have no feeling for colors (to a point where my fiancee decided I can no longer buy my own clothes) but I love WPF. DataBinding support for example is amazing not to mention how easy it is to create a ItemTemplate for a ListBox (remember overriding the draw methods in Windows Forms just to get 2 lines of text and an image in a ListBox item?)

As for performance... in my experience the improvement can only be noticed if you're using Windows Vista / 7 with a GPU. (And of course the way you write code).

Perhaps it was a mistake by Microsoft to market that WPF is all about pink elephant graphics while it does so much more. (They made a similar mistake with the rushed release of Silverlight 1, which in my opinion they should have skipped all together).


WPF

  1. allows a designer/non-programmer to improve the appearance of the UI, separate from the code. Designers can use tools like Expression Blend to heavily modify the look of an app.
  2. the knowledge required for writing WPF is almost entirely transportable for writing Silverlight code, so you are climbing one learning curve for two technologies
  3. is heavily and actively promoted by Microsoft, and has probably more future than WinForms. WinForms will go the way of MFC before WPF does.

on the other hand:

  1. the learning curve is heavier for WPF than Winforms
  2. designer support is lacking compared to Winforms, although this may change with Visual Studio 2010
  3. the current trend is to use View-ViewModel-Model to build applications: this is further learning on top of the WPF framework, but is worth the effort if you are going to build anything beyond simple UI's

If performance (speed and resource requirements) is your criteria for a good UI platform for Windows, then the winner is a native Win32 application. You adopt another technology for what they have to offer, and ultimately WPF has more to offer than WinForms.


Biggest issue with WPF is that the toolset is lame and learning curve is huge. So far uptake on WPF has been very low mostly because of the issues I just mentioned. According to Microsoft WPF is the future and they have invested heavily in it. Infact next version of Visual Studio is written in WPF (http://www.onedotnetway.com/writing-visual-studio-2010-shell-in-wpf-reflects-confidence/)

However it still remains to be seen if WPF will ever become mainstream. The framework is awesome and it can do really cool stuff mostly related to eye-candy. Microsoft calls it UX but in plain English it is eye-candy. Most of the applications don't need it.


The biggest reason to go with WPF isn't eye-candy. The real gains are in terms of reliability, productivity, and allowing the artistic types to modify the appearance of your UI without involving engineers.


WinForms and WPF are both great frameworks the question is what is best suited to your application. If you need a fluid gui with animated controls and very themable styles, or are just creating a very graphical user interface WPF is very good for that kind of application. WinForms can be very limiting at times because the controls are what they are you can create user controls to add things to them but changing their appearance can be difficult if you have a very specific look in mind.

A good comparison would be looking at the difference between a WinForms application and a silverlight application. Silverlight and WPF share a common framework and it will help you to understand the differences between the two.

Have a look at this silverlight and wpf library and you will see some of the things that can be done in a wpf environment.

Silverlight Library: http://demos.telerik.com/silverlight/

WPF Library: http://demos.telerik.com/wpf/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜