views:

317

answers:

4

I've been playing around with C# console applications for about a year and I want to move on to creating GUI applications. I have never done any GUI development besides basic Java applications, but I want to continue using C#. Should I start learning Windows Forms or jump straight to WPF? Is there a huge difference? Does WPF build on top of Windows Forms or are they totally different?

+16  A: 

If you're just starting out, jump straight into WPF.

It will allow you to get starting making Rich interfaces using markup to define your interface without teaching you the possible bad habbits (for WPF) that you'd learn from WinForms.

Justin Niessner
+1 I absolutely agree. WPF is far more flexible than Windows Forms and it is the long-term in GUI development. It's very close to HTML in how you use an XML-based layout. The best argument for Windows Forms right now is if you have a dev team with major experience using it. WPF is the future, and it already is leaps and bounds ahead of Windows Forms.
masenkablast
+1 but, WPF is only usable from .NET 4.0+ because of the font issues in previous versions, so keep that in mind for application deployment.
Fauxide
@Fauxide WPF is usable in .NET 3.5. There have been plenty of useful apps built...font issues aren't a show stopper for everybody.
Justin Niessner
+1 - Done WinForms for years, now in WPF. Never to look back ;) WPF is a lot nicer, a lot faster. Was using only 3rd party controls in winforms for years - now I use them, but not ONLY (i.e. the standard controls are usable, 3r party is not a replacement but new stuff). Especially with .net 4.0 - wpf rocks. Oh, and I do high performance data visualization (a.k.a. financial instrument trading application).
TomTom
+1 WPF has a bit of steep learning curve, but once you've learnt it it's fantastically powerful. Make sure you start with the MVVM pattern though, it just makes sense.
Groky
Thanks for the answer. WPF it is.
Luminose
A: 

I don't know much about WPF. However, I have been aware of some buggy behaviour in a conference from a local .NET community such as, for example, having to go to the code to add a control to the interface. Is it still actual?

Will Marcouiller
Never had that problem in WPF but in winform the _only_ Way of adding controls is code
Rune FS
It never was actual.
TomTom
Well it's true if you consider XAML 'code'. Persoanlly I believe that in WPF you don't have to go to the DESIGN SURFACE to add controls. In WinForms adding controls in code was rather painful thanks to all the properties that had to be set so building pixel perfect interfaces required steady hand or editing the designer files. In WPF defining controls through XAML is so much easier. The design surface is still there though if you want to use it; most just don't.
Mikko Rantanen
Thanks Mikko, that is what I meant. Just dropping the control in design wouldn't add the control in the code, making the control disappear somehow or something like that. That must be what you explain with XAML code. So it is actual. You will sometime have to go to the design and see what your interface look like, and perhaps wantto move a control in design to adopt an ergonimic fashion. How would WPF/XAML behave then?
Will Marcouiller
No, no. At least I haven't had any problems with the changes in Designer not propagating to the XAML (Not that I really ever use the designer). What I meant is that XAML provides so accurate and easy way to define the UI that after a while there's no reason to use the Designer. Also WPF encourages the use of layout containers for laying out the controls which further reduces the need to do some small tweaking in the design surface.
Mikko Rantanen
These precisions are good. What I don't get though, is that it is very seldom to have to design a pixel-perfect GUI. As long as the TextBoxes, Buttons, ComboBoxes, etc. are well aligned, it's sufficient for a good user experience of your application. Why this need of so deep precision? In Web, I get it as aligning two pieces of a same picture requires extreme precision as only one pixel difference is seeable. However, when there are no image to be aligned, but only text information to be input, does it require such precision or so? I doubt. I nevertheless like what you say in your own answer.
Will Marcouiller
Thanks any for everyone's answer. I shall get interested into WPF a little more from now on. (As I upvoted the qestionner.)
Will Marcouiller
+3  A: 

These two are totally different technologies. They do offer some interoperability layers to both directions but other than that have nothing in common. WinForms is more or less a lightweight wrapper on top of Win32/MFC, which means it's extensibility in .Net is not that good in all cases. WPF is a new UI framework implemented from scratch. WPF is also much more flexible when it comes to customizing the existing types.

However, at least from my experience, WinForms seems to be the more commonly used desktop UI framework in the industry. WinForms can't be used with web development though while WPF offers SilverLight and XBAP applications.

If you have done any UI development before, I'd dare say WinForms is easier to learn as it follows more traditional programming paradigms. The programming model of WPF is quite different to this. While WPF can be used in the same way as WinForms, most of its benefits are not achieved until you embrace the data binding and encapsulation WPF provides.

Despite stating some points in favor of WinForms choosing WPF over WinForms would be no brainer for me if all you want to do is learn an UI framework. It's superior to WinForms in all aspects. I just wish the software industry in general would adapt it on larger scale! (Though not like anyone writes desktop applications anymore since we got the web.)

Mikko Rantanen
+1 Totally agree.
Will Marcouiller
+1  A: 

WPF provides very rich facilities to build extremely complex user interfaces. It simplifies integration of a hardware-accelerated graphics in your interface. However, Visual Studio wpf designer is really bad ( i almost never use it ). I also think that WPF is much more complex, and it is more difficult to start with. But this is subjective of course.

n535