views:

5097

answers:

9

For a brand new application, is it better to use WPF over WinForms? I used WinForms before but not much WPF. AFAIK WPF is the successor to WinForms, right?

The application is gonna host DirectX windows (not WPF 3d, but managed dx / slimdx) with lots of custom controls.

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

+5  A: 

----EDIT 2 -----

Given that you're trying to make an editor like the one you showed, I'd recommend going WPF even more. My current project has many features along those lines, as well, and we've decided that the ability to composite WPF with Direct3D content is extremely powerful. It's nice to be able to render your scene into anything - not just a rectangular window. In WinForms, you pretty much were limited to one rectangle, and you had issues with airspace there, too (subtle, but things like flickering issues when menus pull over your hwnd, etc). The WPF compositor with D3DImage gets rid of all of those issues, and lets you use your imagination to construct a very flexible UI. Things like rendering your scene in realtime on the side of a WPF3D object are possible, or using WPF controls directly on top of your d3d scene instead of trying to do the GUI in D3D, etc.

-----Original---------

If you're going to be hosting DX, you might want to consider it - especially since it gives you the ability to do scene composition with your UI and no airspace issues if you use D3DImage.

This does work with SlimDX and WPF.

----EDIT-----

For more information on the disadvantages of using Direct3D with Winforms, and the advantages of WPF/DX integration, see:

MSDN Article on Airspace

Codeproject arcticle on intro to D3DImage

Reed Copsey
Thanks. What's airspace?
Joan Venge
+3  A: 

If you're writing lots of custom controls I would choose WPF. Part of WPF's design is to be extendable, composable and the result is that it's dirt simple to write custom controls.

I've done a bit of custom control writing in WinForms and it can be very challanging at time. Layout will really take some time away from you. Several weekends of my life were paid to WinForm Control Layout. Writing the equivalent controls in WPF was a cinch.

JaredPar
+2  A: 

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.

Dan Blair
Well, Vista was the successor to XP, but it wasn't meant to make all Vista platforms defunct. WPF was and is intended by MS to revamp the fundamentals of WinForms while fulfilling the same niche.
You'll be surprised, I think!
Tor Haugen
+12  A: 

We dealt with this question about 9 months ago. We decided to go with WPF and so far we're happy with the decision. Yes, there is a learning curve. It's fairly considerable especially coming from WinForms where you have so much to unlearn. I also recommend you have access to a designer otherwise your application will probably look a bit shabby. Also be prepared for some WPF gotchas that will have you spending hours scratching your head saying 'why was this so hard'.

But WPF is a step ahead. The data binding, templating and complete control of how you want your windows to look makes you think that this how WinForms should've been originally.

Oh yes, and be prepared to shell out a couple of dollars for some missing controls. There are a couple of things missing like a Date picker and having checkboxes on tree controls (you can actually template this out, but it's not as simple as winforms in that regard). 3.5 SP1 includes a grid control now, thankfully.

I'm sure I'm missing a bunch more, but that's what I can come up with off the top of my head.

Good luck!

billb
Both the DatePicker and DataGrid are part of the WPF Toolkit, which requires .NET 3.5SP1. http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=22567
Andy
+3  A: 

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.

Brian ONeil
+2  A: 

In this case, I'd say follow the lead of your Vendor (i.e. Microsoft). Their own internal production increasingly features WPF; and it's scope (think Silverlight) and depth are clearly greater than WinForms. They also use it increasingly with reference to Best Practices. From all the evidence (here and elsewhere), it appears to be ready for Prime Time developement.

You have epressed no particular affinity for WinForms (I would guess what there is is based on familiarity). You'll need to switch eventually. A new project would be a great place to start the process, everything else being equal.

le dorfier
+2  A: 

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.

Cameron MacFarland
+3  A: 

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.

sipwiz
A: 

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 WinForms (like rapid development of business applications). I'm using Wpf to write a nice GUI for a media center app (personal project for a media console on my 50' plasma). However, if I'm writing a data entry/display application, I typically go with WinForms for speed of development. The Xaml editor is better in VS2010 but still has a way to go. Without a reference there's no intellsense 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 UI's.

John