tags:

views:

362

answers:

8

What is WPF to the WinForms programmer?

WinForms distilled is adding controls to forms, and adding event handlers. This is simple and easy and allows you to make functional GUIs quickly.

WPF on the other hand is XAML (?) + Code (?) that seems like a much more complicated way to make prettier UIs slowly.

There are plenty of existing SO questions on aspects of WPF but I'm looking for a two sentence blub on how to grawk it. Should I just focus on learning XAML? Or is real WPF written by directly accessing the classes and writing code (like Winforms)?

Also, what practical benefit would a WinForms programmer like me see from using WPF? 3D graphics, arbitrary zooming of text, and custom 'skins' for applications are not valid answers. What does WPF offer an app used to track shipping orders.

A: 

Visual Studio 2008 contains a WPF Designer.

This video might be of interest: Create a C# WPF Application in Visual Studio 2008

Mitch Wheat
+1  A: 

I suppose one way of looking at it would be to consider HTML + CSS webpages. We had HTML and that was great, except things were all jumbled together. What people realized is that with CSS, you could separate the structure of the document from its presentation. XAML does the same thing, or at least allows and encourages it.

As for practical benefits, skim through the MSDN examples. I tend to think WPF is more geared towards so called "rich media", with much more complex elements. Your example of an app that tracks shipping orders isn't a good one, particularly since a number of those systems still run in DOS based interfaces.

Promit
+3  A: 

Read this article. Then, watch this video.

JP Alioto
Good article, but it doesn't match the "...I'm looking for a two sentence..." request
MrTelly
You can't summarize certain things in 2 sentences. E.g. What is the book Zen and the Art of Motorcycle Maintenance about... in 2 sentences?
Gishu
My answer is 2 sentences or less -- does that not count? It's apropos to SO b/c all problems in CS are solved by another level of indirection. :)
JP Alioto
It's about Zen. And motorcycles.
Tiberiu Ana
A: 

The XAML part of a WPF application is vaguely a replacement of the WinForm.Designer.cs file in WinForms.

The WPF model has a better design for the UI and individual controls, fixing a lot of the short-comings of WinForms and guides you to (hopefully) a better Seperation of Concern design.

benPearce
A: 

WPF should be every WinForms programmer's dream: instead of procedurally doing every little thing, it let's you say what the controls are, where to put them, what they look like, and to some extent even how they behave in XAML, while letting you customize behavior in the "code behind". Oh, and the designer can do a lot more for you now than before because of the declarative nature of XAML.

Ben Collins
+5  A: 

WPF brings

  • Declarative UI Programming: The presentation or look of the UI (XAML) has been separated from the code (.cs et. all) such that the XAML can be created independently by people who are good at that sort of thing - graphic designers. They then submit their finished look to the developers who just write the code to make it work. (Simpler stuff can be handled again directly in XAML) Supposed to give you greater parallelism and good UX (as opposed to developer-approved-UIs)
  • Data Binding: Again a declarative bent.. You declarative specify which model property this UI control renders, WPF takes care of pulling the data into the control & updating modified contents back along with change notifications.
  • Improved Composite Control Model - You can now embed almost anything within anything so now imagination knows no bounds.
  • Data Templates, Control Templates etc.. - again separation of UI from code. These XAML templates specify (once) how a data structure or UI Control should look to the user.
  • Better at X: Ofcourse MS improved on a bunch of other aspects like rendering (fewer updates that GDI), Scaling (resolution independence), Transparency, Layouts (Non-absolute), Text rendering, Animation & Video support, An Improved Event Model, et. all
  • Styles, Triggers : Easier to apply uniform look-n-feel globally with in-one-place styles (XAML again). Triggers are blocks of code that execute when some event occurs e.g. 'the text of this control changed.. so now update its foreground property to blue to indicate "modified"'. Simple stuff can be done directly in XAML.
Gishu
Nice detail but you need a prècis: WPF is markup for UI, à la HTML, with direct support for most of GDI+ and extensive explicit binding for UI events.
Peter Wone
A: 

I found XAML to be a bit complicated, too, at the beginning, but once i got used to it, i found it to be pretty simple (once you know the basic controls). One of the best things about it is Databinding.

Usually when i write a WPF application, i use it for pretty much everything on my UI. Binding controls to Commands and properties of a viewmodel can completely separate presentation from design, i usually have not a single line of code in my code-behind. That makes my ViewModel/business logic objects easily testable and completely independent from any visual representation, which in turn can be easily replaced.

Botz3000
A: 

I've been working almost exclusively in WinForms for the past 4 years and have begun using WPF for a couple of small projects at work. The learning curve is steep. But once you get used to it, it's well worth it.

WPF is much more than just visual eye candy like skinning or animation. Even for basic applications to track shipping orders, you can leverage WPF. WinForms only takes you so far with its controls. If you wanted to display slightly customized UI, you often needed to do custom draw in your controls using GDI, which can quickly become a nightmare. In WPF, customizing anything is trivial through data templates. You can easily customize list box elements, add controls to list view columns, or headers, etc. WPF allows you to take control of complex UI layouts with its powerful layout system. I'm also amazed at how little code is needed in WPF to accomplish the same things I used to do in WinForms, so this means less bugs and easier to maintain applications.

Anthony Brien
If you can, please site a reference or two of any existing documents or tutorials for "WPF for Windows Forms" programmers. That would be useful.
zumalifeguard
WPF and WinForms have very little in common actually, so any tutorial should do. A good place to look at is http://www.wpftutorial.net.
Anthony Brien