When creating a new GUI, is WPF the preferred choi

2019-01-03 18:47发布

Most restrictions and tricks with windows forms are common to most programmers. But since .NET 3.0 there is also WPF available, the Windows Presentation Foundation. It is said that you can make "sexy applications" more easy with it and with .NET 3.5 SP1 it got a good speed boost on execution.

But on the other side a lot of things are working different with WPF. I will not say it is more difficult but you have to learn "everything" from scratch.

My question: Is it worth to spend this extra time when you have to create a new GUI and there is no time pressure for the project?

30条回答
Summer. ? 凉城
2楼-- · 2019-01-03 18:58

WPF makes it much easier to hand off the forms design work to an actual designer, not a developer in designer's clothing. If that's something you'd like to do, WPF is your answer. If the classic Windows styled buttons are fine, then Windows Forms is probably the way to go.

(Multiple answers make the claim that you should use WPF if interface design is "important to you" but that's pretty vague. Interface design is always "important".)

查看更多
来,给爷笑一个
3楼-- · 2019-01-03 18:58

If you decide to go with WPF, considering pros and cons already explained in the above answers, I highly recommend going through this dnrTV episode with Billy Hollis

查看更多
叛逆
4楼-- · 2019-01-03 19:00

Both of technologies have their pros and cons. In a large application with a "classic" UI I'd use Windows Forms. In an application which require a rich user interface (skinning, animations, changing user interface) I'd choose WPF. Please check the article WPF vs. Windows Forms comparing WPF and Windows Forms.

查看更多
萌系小妹纸
5楼-- · 2019-01-03 19:00

WPF comes with many advantages such as superb data binding features, separation of concerns, separation of design and logic etc...

As a developer I enjoy the ability to define my UI using XAML as opposed to being tied to the Windows Forms designer and I feel good knowing I can count on another designer to make my app look good.

Personally I don't care older versions of Windows are not supported, but one of the big problems with WPF is that is is not (currently/ever) supported by Mono (http://www.mono-project.com) so WPF apps will not run on Mac OS or Linux. (Altough Silverlight applications will).

If you have the time and resources to invest in learning WPF, do it! Even if you're going to be writing Silverlight applications to support multiple OS's.

If you need desktop applications to run on multiple OS's stick with SWF.

查看更多
做自己的国王
6楼-- · 2019-01-03 19:00

If you have an MSDN license, check out Expression tools. It's designed explicitly for WPF, exports directly to Visual Studio and it may help ease your transition.

查看更多
神经病院院长
7楼-- · 2019-01-03 19:00

A quote from an earlier post from Mark:

  • In Windows Forms you design your user interface, then write code to drive that user interface, which generally also includes code to drive your data objects.
  • In WPF you invest in the business layer that drives your data objects, then design an interface that listens to your data objects.

I would argue that this is more of a design choice, rather than whether or not you are using Windows Forms or WPF. However, I can appreciate that certain technologies might be better suited for a particular approach.

查看更多
登录 后发表回答