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条回答
对你真心纯属浪费
2楼-- · 2019-01-03 19:04

The advantages of WPF is that it is much easier to create nice looking GUI's with custom controls and animations. WPF also helps further serparate the presentation and logic layers. If you have designers, it allows you to farm of 95% of this work to non-coders and allows the coders to work on logic. The disadvantages are the software costs for Expressions Blend, and the lack of any of the Visual Studio code profiling tools working well as they tend to get caught up in the frameworks calls in trying to render XAML. I am sure there are others but these were the only two we really saw.

The main consideration is if you wish to require your customers to have to install .NET 3.0 or even better .NET 3.5 SP1. You will get some niegative feedback

查看更多
狗以群分
3楼-- · 2019-01-03 19:04

In DotNetRocks episode 315, Brian Noyes discusses this extensively.

查看更多
Root(大扎)
4楼-- · 2019-01-03 19:05

As others have said, there are advantages and disadvantages either way you go here. The advantages of WPF, as others have said, include:

  • The ability to make very rich UIs relatively easily.
  • Easier animation and special effects
  • Inherent scalability (use the Windows Vista magnifier tool on a WPF application, and on a Windows Forms application: Note that in the WPF application, all the vector art scales beautifully)
  • (OPINION ALERT) I feel it's "easier" to do document-oriented systems in WPF

However, there are drawbacks to WPF, where Windows Forms comes out on top:

  • WPF's in-box control suite is far more limited than that of Windows Forms.
  • There's greater support in the third-party control space for Windows Forms. (That's changing, of course, but think about it: Windows Forms has been around since 2001; WPF just a few years. By advantage of time, Windows Forms has greater support in the community.)
  • Most developers already know Windows Forms; WPF provides a new learning curve

Finally, bear in mind that you can create great, attractive and engaging UIs in either tool, if you do the work (or use the right third-party tools). At the end of the day, neither is necessarily better in all circumstances. Use what feels right for the project.

查看更多
放荡不羁爱自由
5楼-- · 2019-01-03 19:07

Aside from the flexibility in UI design, there are some technical advantages to WPF:

1.) WPF doesn't rely on GDI objects. Well, I think it uses 2 GDI objects for the instance of the window itself, but that's practically nothing. I've been involved to a certain extent in a very large internal Windows Forms application. The people in our office sometimes run 3 or 4 instances of it simultaneously. The problem is that they frequently run into the 10,000 GDI object limit inherent to Windows 2000, XP and Vista. When that happens the entire OS becomes unresponsive and you'll start to see visual artifacts. The only way to clear it up is to close applications down.

2.) WPF utilizes the GPU. The ability for WPF to off-load some of the UI processing to the GPU is brilliant. I only expect this aspect of it to get better with time. As a former OpenGL programming hobbyist I can appreciate the power that comes from the GPU. I mean, my $100 video card has 112 cores running at 1.5 GHz each (and that's not top of the line by any means). That kind of parallel processing power can put any quad-core CPU to shame.

However, WPF is still pretty new. It won't run on Windows 2000. And in fact, a WPF application can be slow to start up after a fresh reboot. I talk about all of this on my blog: http://blog.bucketsoft.com/2009/05/wpf-is-like-fat-super-hero.html

查看更多
我想做一个坏孩纸
6楼-- · 2019-01-03 19:07

Scott is complaining about Expression Blend and how it doesn't make sense to him as a developer. My first reaction to Expression Blend was like that. However, now I see it as an invaluable tool, but it really depends on what type of developer you are.

I am user interface developer that has had to perform the Integrator role, and I eventually found Expression Blend invaluable to create styles, and control templates in a WYSIWYG manner. I almost always have Expression Blend and Visual Studio up an running on the same project at the same time.

I also think that playing around in Expression Blend and taking a look at the XAML that gets spit out is an excellent way to learn the WPF API ... much like using the designer in Windows Forms and checking the C# code it spits out is helpful in learning how to use whatever you are designing there.

Expression Blend is helpful. Just give it a try, especially if you are working on the visuals for the application.

查看更多
Juvenile、少年°
7楼-- · 2019-01-03 19:09

Consider WPF if interface design is important to you, because WPF can deliver better UI experience. But Windows Forms has on its side the years of evolution, so it's proven to work and you can find many versed programmers for that platform.

Also portability may be an issue, WPF only works with Windows XP SP2 and up.

Also, WPF has a steep learning curve, meaning it's not easy to deliver a quality product without having specific WPF experience.

查看更多
登录 后发表回答