Is it better to use WPF over Windows Forms?

2020-02-09 01:22发布

For a brand new application, is it better to use WPF over Windows Forms? I used Windows Forms before but not much WPF. As far as I know, WPF is the successor to Windows Forms, right?

The application is going to host DirectX Windows (not WPF 3D, but Managed DirectX and SlimDX) with lots of custom controls.

EDIT: The application is a 3D related application, editor, such as modo:

Image created using the 3D painting program modo.

10条回答
smile是对你的礼貌
2楼-- · 2020-02-09 01:30

AFAIK WPF is the successor to WinForms, right?

I don't believe this is true as much as MS might like to push this. There is just too much legacy code written on Winforms for that to be a realistic thing in the near or even somewhat distant future.

So with that in mind, if you would like to, and can afford to spend the time learning WPF I would do that. Otherwise I would use Winforms.

查看更多
相关推荐>>
3楼-- · 2020-02-09 01:30

In your case, WPF makes sense. For me, it's an application by application choice because there are a lot of things you can do really well in Windows Forms (like rapid development of business applications). I'm using WPF to write a nice GUI for a media center application (personal project for a media console on my 50-inch plasma screen).

However, if I'm writing a data entry and display application, I typically go with Windows Forms for speed of development. The XAML editor is better in Visual Studio 2010 but still has a way to go. Without a reference there's no IntelliSense help on a lot of the property attributes so it's impossible to know what goes in them (which is where I spend a lot of my time trying to find those values, either through a book or examples on the web). That said, if you do WPF write, you can make some very compelling user interfaces.

查看更多
迷人小祖宗
4楼-- · 2020-02-09 01:31

We just went through this too… we started a move to WPF over WinForms. I think that these days it is a pretty easy decision to put WinForms behind you. The tooling is getting better and better and if you can get a true designer on your team there are very few things that you can’t put together.

We are starting to realize that our future is actually not WPF, but it is Silverlight. As Silverlight matures it is becoming more and more on par with WPF and it allows you to run cross platform. The path of Silverlight is more like Adobe Air and one day it will live outside the browser (actually you can do it now, but it is a pain). I really think that the future for .NET UI is going to be Silverlight.

查看更多
走好不送
5楼-- · 2020-02-09 01:31

Having just recently done a very similar product (3d viewer for mining data in WPF) I can definitely recommend WPF/SlimDX.

The tools are a bit lax (especially Visual Studio), but WPF makes it much easier to make an app with a bit of Zing, rather than the default control grey that most things have.

Using D3DImage from 3.5SP1 it's very easy to host a SlimDX device inside a control.

Overall I'd say WPF isn't better to use, just different. Some things are better, some are worse. But it's definitely the future.

查看更多
▲ chillily
6楼-- · 2020-02-09 01:36

I know this is an old post, but I think it's still a valid question.

I used WinForms for 3 years at the first company I worked for. There were some really good programmers there, and they found some very clever ways to do some very cool things. WinForms has stood the test of time. It is a solid, reliable and efficient platform. Many people, and many companies both large and small have been using WinForms for years, and the technology has proven itself time and time again. Inertia like that is hard to fight, even if you are Microsoft.

Still, WPF is definitely the future. Microsoft made that clear by making products such as Visual Studio 2010 and Expression Blend with it. (In using WPF for internal projects, Microsoft was forced to fix many of the issues, such as font rendering and speed issues, that prevented people from adopting it at first. Visual Studio 2010 shows that WPF has long been ready for production.

So, is it better to write your program in WinForms or WPF? The answer is this : WPF. I say this for two reasons. Firstly, because Microsoft is supporting it internally, we can assume that it will be around for a very long time. Microsoft has shown us that it is the next tool of choice which leads me to my next point: it has become superior to WinForms (some people I have spoken to disagree, but it is the truth nonetheless, and is becoming more obvious every day). WPF has a host of features that WinForms will (probably) never be given, such as integrated support amazing data binding, and timeline based animations that make it easy to make amazing themes for your apps, and will have designers begging to make the switch. There is much more to WPF than can ever be described in a comment, but these are two big ones for me :)

This being said, I know there is nothing you can do in WPF that you cannot do in WinForms. You can do anything in any language if you want to badly enough. The point is that where WinForm's will leave you scouring google for how somebody else did something cool, WPF ships with built-in support for all the features that Microsoft considers to be the future of Windows and puts them right at your fingertips.

Over time, people will become used to new features build directly into Windows, and will come to expect them to be available in all the applications they use. This will reach the point where anything that doesn't support them will feel clunky, less usable, and seem less worth spending money on. (I see Touch integration as the most obvious example of this. Although there are touch screen solutions that clamp onto a monitor and emulate a mouse, on any computer, touch screen technology has come a very long way, and with Windows 8 blurring the line between the desktop and mobile devices, people will likely want to use applications in a way that will be exceptionally difficult to implement if your application uses WinForms.)

Sooner or later, I believe that support and development for WinForms will stop, and everybody that left themselves behind will be forced to port, and quickly. However, there are too many programs out there that rely on WinForms for Microsoft to be able to drop it in the near future. Who knows what will happen. Perhaps WinForms will be to Microsoft what Itanium Processors are to Intel, the product that has enough users that to keep it going, even though there are better solutions available. ( http://arstechnica.com/business/news/2011/06/ask-ars-why-itaniumask-ars-with-xeons-improvement-why-bother-with-itanium.ars )

So my advice would be this: regarding new development, make the switch to WPF. Send some staff on training courses, or let them play for a while so they can get a better feel for the technology. The learning curve is going to be steep, but doing this will increase your team's skill set because by learning WPF, they will also be well on their way to learning SilverLight, which is similar enough to WPF for people familiar with WPF to be be able to learn it quickly, but is designed for the web rather than the desktop. This is valuable because apps rewritten in WPF will far easier to convert to Web Apps later down the line. WPF is new, but it was made for a reason, not simply for the sake of making something else for people to learn. It was designed to make applications more user friendly, intuitive, and portable. It was designed to help developers make their applications fit into the new age of computers.

Regarding applications written in WinForms : I think it's safe to assume that WinForms will still be supported for quite a long time simply because of the amount of support it has gained. I would recommend letting your team familiarize themselves with WPF, and slowly start moving your applications over to WPF. Take all the time that Microsoft allows and don't rush the process, but always keep in mind that, one way or another, WinForms day's are over, and although nobody can be sure what will happen, support for the legacy product will be dropped as soon as it can be justified. Even if WinForms applications are kept around for many years, it is important to remember that times are changing, and we all need to change with them.

查看更多
一夜七次
7楼-- · 2020-02-09 01:36

I found that once I got a handle on Expression Blend and WPF I was more productive at building UIs than with Windows Forms. To my mind that's one of, if not the, biggest factor with a new technology/tool; if you can't acheive the same result as the old tool faster with the new tool then all the bells and whistles, that you only use 10% of the time, won't make up for it.

Apart from that there are other advantages WPF has over Forms:

  • Having the interface in XAML makes it so much easier to fine tune all those obscure properties or to cut and paste a whole section of one control into another,

  • WPF makes it a lot easier to modularise an interface, breaking a screen down control by control. Forms can do the same to an extent but I always found it a battle,

  • Some of the bells and whistles are cool. I've found the use of animations (storyboards) really useful for data entry screens where you need different entry boxes depending on which product is chosen or such. With Forms you'd have to create a separate panel/form for each data entry screen, with WPF I use an animation to hide and move the various text boxes around.

查看更多
登录 后发表回答