Take the 2-minute tour ×

Windows Forms is pretty old now, and has been superseded by WPF. I've seen a lot of material regarding databinding WPF layouts, using the MVVM pattern for the applications and some cool animations to boot.

I think it's time for me to abandon the Winforms ship and start using WPF. Once I finish this last freelance project I'll start using WPF exclusively for my Windows Clients.

I have the privilege of having customers with newer machines, so running WPF on their machine won't be a problem. :)

Trying to grab the entirety of WPF is extremely daunting and I feel that if I just dive right in I might keep doing things the Winforms way when in fact WPF has a newer, more succinct way of doing things.

Where do you recommend I start? What are some things you wish you knew before using WPF for production? What book would you recommend that teaches you about WPF (has to be new! nothing from 2007)?

share|improve this question
Maybe a bit early, but I personally would recommend that you take a look at the design pattern MVVM early on. A good video introduction available here: blog.lab49.com/archives/2650 –  eandersson Feb 4 '11 at 22:39
Since I'm familiar with MVC, will the transition to MVVM be great? I mean it's basically the same thing except with a ViewModel correct? –  delete Feb 4 '11 at 22:43
Not quite as far as i know; MVC describes a triangle of sorts while MVVM is a line with the viewmodel in the middle, also MVVM relies heavily on WPF's databinding capabilities. –  H.B. Feb 5 '11 at 0:14

6 Answers 6

up vote 1 down vote accepted

I've just done the exact same thing. I am in the process of moving some apps to WPF. I've decided not to bite off MVVM just yet, or any VM. I'm just trying to learn the basics of WPF. I have found SO, other internet sites and this book very helpful.

BTW, I'm finding it's much easier than I thought. Takes some getting used to, but I'm already hooked (XAML is very cool). I'm convinced the best to learn is to simply jump in and start doing it.

share|improve this answer

The main advice I can give is to "forget" what you have learned with winforms. Do not try to apply what you did with winforms to wpf... The architecture is quite different and you risk to fall into traps.

Maybe MVVM is not required at your early stages of learning, but its approach make the WPF coding easier than without. Take a look not so late at the MVVM Light Toolkit. This MVVM framework is really light but provide what is required for a full MVVM framework, and only that.

good luck, and do not hesitate to take a look at Silverlight also. The border between the desktop apps and web apps are as slim as ever.

share|improve this answer

How I'd start teaching someone WPF today:

  1. Make sure they have a solid grounding in XML. If you don't know how to edit XML documents and diagnose and fix problems in markup, you're not going to be able to make progress with WPF. You especially need to be able to work with XML namespaces and understand namespace prefixes without freaking out.

  2. Create an example application that creates a bunch of text boxes and binds them to the properties of an object that implements change notification. Data binding is the fundamental technology of WPF, as far as I'm concerned. Once you understand binding - and it's not that hard to understand, really - the design of things like dependency properties and styles become a lot easier to grasp.

  3. Add additional object types to the application and demonstrate how data templates and template selection work.

  4. Add styles, particularly styles that use data triggers, to the example application.

  5. Add items controls to the example application and demonstrate how items panels and item container styles work. Maybe take a little journey into the different kinds of panels. Walk through how observable collections and INotifyCollectionChanged work. At this point I might possibly create a piece of the example collection that used an ItemsControl with a Grid as its items panel, so that I could walk through item container generation and attached properties.

  6. Refactor the example application to move styles and data templates into resource dictionaries, to demonstrate how resource dictionaries work.

  7. Walk through the design of dependency properties, tying their design back to the concepts we've already mastered. To show this off, I like to add a modal dialog that contains a font-selection combo box for the entire application.

  8. Add commands (using the RelayCommand pattern) to the back-end objects, to demonstrate how commanding works.

  9. Refactor the example application to use user controls.

  10. Walk through customizing a control template.

I don't know of any WPF tutorial that approaches the problem like this, unfortunately.

share|improve this answer

What i think is most important:

  1. Databinding, one of the most outstanding features of WPF, takes a while to get used to though.
  2. Commands, not sure if there is something like this in WinForms...
  3. DataTemplates, create large parts of the UI on the fly based on data.
  4. Styling, if you need customized controls.

Also you should probably acquire basic XML knowledge if you don't have that already to be able to write XAML (I wouldn't use the designer in VS).

share|improve this answer

I would heartily recommend the book WPF Unleashed by Adam Nathan. It's how I learned WPF, and I still reference it regularly now, years later. Great introduction that explains things in a clear order, gradually building up skills.

I echo what was said above - forget much of what you know in WinForms. If you try to think of WPF as a "prettier WinForms" you'll not get the full benefit of the platform. Learning to "let go" a bit and embrace Data Binding (SO much better in WPF), and to embrace the idea that controls don't have speficic visuals, then you will be truly free to use WPF to its fullest.

share|improve this answer

'WPF in Action' is a great book to read before starting any coding. Its very simple to understand and if you have the patience you can go through the entire book in a day or two. It doesnt have any MVVM stuff so for someone coming from a winforms background its great to start with.

Once you 'get the hang' of WPF concepts you can jump into MVVM. Two great MVVM resources I found when learning all things WPF were

1. Video by Jason dolinger

2. MSDN article by Josh Smith

share|improve this answer

Your Answer

