views:

335

answers:

5
+9  Q: 

Winforms vs WPF

I am a student and I do freelance here and there when I have opportunity. I believe my strongest language is C#. I don't really know what is going on in real programming world, so I was wondering if WPF did take over WinForms? I know the differences between two and how two can be used simultaneously but, I just don't want to invest my time in learning dying technologies, I hope you understand.

So, for windows desktop programming what would you recommend to master WinForms, WPF or maybe both? I also get a lot that desktop programming is dead already and one should only care about learning web programming.

+15  A: 

It depends who you ask ;-p

Winforms is probably easier to pick up, but has less long-term future. WPF has a steep learning curve, but is more flexible, and the approach (xaml etc) is usable in more places ("Silverlight", "Phone 7"), and more portable ("Moonlight" etc).

Most MS future efforts are towards WPF, but winforms still lives on. People are moving, but slowly. I suspect more slowly than MS would like.

As for desktop programming being dead... again, it depends on your market. If you are writing apps for random visitors, then a browser app (perhaps HTML 5) is a good bet. For complex business code a desktop app is valuable, although Silverlight has out-of-browser now (but not the full runtime). And don't forget "mobile" - a huge growth area. Lots of people writing non-browser apps for those. Oh, and consoles, set-to-boxes, etc. Not everything is a browser.

Marc Gravell
On Windows side, WPF is the recommended (even VS2010 uses WPF instead of WinForms.But the portability about Silverlight, Windows Phone 7 Series, Moonlight is misleading. Silverlight/Moonlight is not WPF. Although XAML is used in both WPF and SL/ML, we cannot simply say they are the same.WinForms is already available in Mono, while WPF won't for a long time, WinForms applications can be brought to other OS (Linux, Mac) more easily.
Lex Li
@Lex - you are right; I meant to say that more clearly...
Marc Gravell
+3  A: 

I would recommend going for WPF. This will also prepare you to do Silverlight applications which share much of the same libraries and programming style as WPF.

And I would disagree that desktop programming is dead. It has it's place for certain applications.

That said, knowing a little bit about WinForms and about Web never hurts. Often you can use concepts across your GUI frameworks.

Mikael Svenson
Let's call them GUI frameworks :) instead of platforms
Lex Li
@Lex Changed :) And a much better word.
Mikael Svenson
+3  A: 

If your only goal is Windows desktop stick with WPF, it's far superior than WinForms. Someone else have to explain details.

But if you someday want to be able to run your application on Mono, then WinForms is a better choice.

On the other hand, you shouldn't be depending on a GUI-plattform to be able to write applications, building nice architechture with MVP/MVC/ more important if you ask me.

Marcus
WinForms may bring your apps to Mac and Linux via Mono, but using GTK# for Linux and MonoMac for Mac make your apps look native there. :)
Lex Li
Ofcourse, thats why I mentioned MVP/MVC. :)
Marcus
+2  A: 

I love WinForms. It's really easy to pick up, you'll see the same concepts over and over.

I had typed up a whole rant about how much of a pain in the ass WPF is, but that's not really important. It's just really different from Windows Forms. Some things are much easier in WPF, while things that would take two clicks in Windows Forms require an afternoon of XAML editing.

WPF's data binding model took me a while to get my head around (in fact, I still only know the basics of it). Control templating is a major annoyance but the results you can achieve make it almost worth it. I feel like the XAML editor isn't nearly as fluid as it should be; I find myself messing around with arrow keys all the time. I feel the UI designer also leaves something to be desired, especially in comparison to the Windows Forms designer. I rarely, rarely use the WPF designer. I just find it easier to write the XAML.

All of that said however, things are definitely going the way of WPF, at least on the Windows side of things. I've noticed newer UI features sometimes are released only for WPF.

My two cents: Learn both. Windows Forms is really easy, at least for me. It just feels natural and completely logical to me. WPF definitely has a massive learning curve, and you'll find yourself bashing your head into your keyboard trying to do simple tasks at first, but in the end it pays off. Know the basics of WPF? Great! That means you can pretty much jump right in to Windows Phone 7 development, which is Silverlight-based. Lot of the same concepts though. Whenever I do personal projects, I decide which technology best benefits the project and go with it. That alone has helped massively with learning WPF, even if it's just stupid little apps that don't do much.

Good luck! :) And sorry for the lengthy post. I could write forever on this topic.

UPDATE: Since I originally wrote this post, I've fallen completely in love with WPF. WinForms is dead to me (except for when I have to make small little utilities).

Eric Smith
+1  A: 

It generally depends on the market you wanna get in and your planned carreer. This is why :

  1. WinForms - There is currently a lot of applications written in win forms, especially in more enterprise like companies. Win forms are easier to learn, and have an excellent support in Visual Studio. Also, more importantly, win forms as a technology is similar to other GUI toolkits out there for other technologies (like Java, C++, Python etc.). So learning the basics of win forms will let you pick up faster another GUI toolkit if you need to swtich platforms.

  2. WPF - There is currently a lot of hype around WPF , mostly due to the ascent of Silverlight. WPF is really good at high end graphical desktop application. One girl I know spent two years developing a 3d modeling application in WPF for use in gene research. WPF follows the web model of declaratevely defining an user interface using a XML based dialect and having the programming logic elsewhere. Now this isn't nothing new, since other technologies have previously allowed the separation of the UI declaration and the UI programming logic.

  3. Silverlight - What makes WPF so popular now is Silverlight which allows programmers to develop web based application without having to deal with the complexity of the web (CSS, HTML and Javascript on multiple browsers). Lets face it , web is hard. A lot of developers have made a transition to the web groundginly. The freedom to develop a web application as you would develop a desktop application its a holy grail to those folks.

Nikola Stjelja