21

I'am more a sysadmin and a webmaster than a developer, but sometime I develop, including C# principally using Winform (and optionally GTK+).

I've started few weeks ago a WPF project, and it seem really powerful, but at start I feel like a hen who found a knife! There is so many difference!

stackoverflow abounds about topic like that, and I've read carefully some who are similar like:

But, when somebody start with WPF from Winform, What are the differences to which he must pay attention?

[EDIT]

  • What about some advices/links for LINQ with WPF?
  • What about some advices/links WPF Navigation?
Community
  • 1
  • 1
Pascal Qyy
  • 4,442
  • 4
  • 31
  • 46
  • 5
    "I feel like a hen who found a knife!" - great analogy :) – Coxy Nov 17 '10 at 07:39
  • 4
    @Coxy: it's a literal translation of a common French expression in such cases, is there some English equivalent? – Pascal Qyy Nov 17 '10 at 07:43
  • 2
    I'd strengthen/refresh XML knowledge if I did winforms for a long time. This may make you feel more ta home too: http://tanveerbadar.wordpress.com/2007/04/23/deep-drive-into-wpf-graphics-internals-part-1/ – ivo s Nov 17 '10 at 07:44
  • @ivo s: XML is not the problem for me, I use it in many cases: I prefer it to database for small website, small software etc, and XHTML is XML, so I work a lot on XML, DTD etc., even SGML Who is "a little bit" more complicated (IMHO). - Hum, pretty interesting link, thank you! – Pascal Qyy Nov 17 '10 at 07:50
  • "a hen who found a knife" Ha ha I first thought wow they use this in english too... then I saw where you come from! – Jla Nov 19 '10 at 14:43

6 Answers6

14

WPF is completely different from other systems.

I have a few years of WinForms, Win32 and web programming experience, and I believe my web programming experience helped the most.

As for books, "Windows Presentation Foundation Unleashed" from Adam Nathan, Sams Publishing has helped me tremendously.

Pieter van Ginkel
  • 29,160
  • 8
  • 71
  • 111
8

to getting started with WPF a design pattern Model View ViewModel (MVVM) would be important to know. also I would recommend Adam Nathan WPF4 book. I think it's great one!

Arseny
  • 7,251
  • 4
  • 37
  • 52
  • Agreed. Learn it as soon as possible, otherwise you'll soon find yourself in the middle of a thousands-file spaghetti code project that is impossible to refactor at the time you realize that mvvm was indeed a good thing. – Francesco De Vittori Nov 17 '10 at 07:55
  • 1
    Some links, some advices? Because MVVM (VVMM?) seem very occult, even with some good explanations like here http://www.wpftutorial.net/ – Pascal Qyy Nov 17 '10 at 07:58
  • @G. Qyy you're right. I fixed it. – Arseny Nov 17 '10 at 08:02
  • 2
    You should check Karl Shifflett's In the Box training for MVVM: http://karlshifflett.wordpress.com/2010/11/07/in-the-box-ndash-mvvm-training/ – Mamta D Nov 17 '10 at 08:11
  • @Mamta Dalal: Wow, great link, thank you! – Pascal Qyy Nov 17 '10 at 08:26
8

Thank you all, but all this is a bit diffuse, so I made a resources compilation and add some things by my own, please tell me what you think (or improve, I make it Community Wiki)

Strangely no one has talked about LINQ which seemed to be a central element of this technology.

Another thing that seems important to know given the time I lost, is not to use the WPF navigation system that doesn't seems to work properly from numerous sources I've read. So, it seem important to use a navigation framework, like Magellan.

And the routed event system seem to be an important point to look at in WPF, if somebody have some interesting resources about it, please add to this post.

RTFM

Software

Blog posts

Videos

The Code Project

Books:

Other Stack Overflow topics

Community
  • 1
  • 1
Pascal Qyy
  • 4,442
  • 4
  • 31
  • 46
4

I agree with Arseny, learning MVVM is core to learning WPF properly. It isn't a niche thing - when applied properly it can make your code cleaner, simpler and promotes decoupling and unit testing.

There is a very nice video here which explains both the concept and implementation: Jonas Follesø explains the MVVM Design Pattern. In the video the guy is talking about Silverlight but the implementation in WPF is pretty much identical.

Once you've watched the video, and you're happy with the basics of WPF you could do alot worse than adopt a framework to take much of the heavy lifting and plumbing off your hands. I highly reccommend Caliburn Micro. This will lead you down the path of best practice by encouraging you to use MVVM but will also take care of much of the coding detail for you. The documentation on the site is a bit thin on the ground but there are a number of tutorials there that are being steadily added to.

For example, when following MVVM you would typcially have a View (e.g. a window) and ViewModel (a C# class). If you had a textbox on the view which contained an order number, you would have a corresponding property on your ViewModel called OrderNumber. Using a WPF Binding expression:

<TextBox x:Name="OrderNumber" Text="{Binding OrderNumber}" />

the textbox would be bound to the property on your ViewModel so that when either the textbox or the property changes, the other automatically updates. Using a framework like Caliburn Micro you don't have to write any binding expressions, it uses a simple convention based approach. In the previous example, if your textbox was called OrderNumber and your ViewModel property was called OrderNumber Caliburn assumes they must be the same thing and automatically binds them for you.

<TextBox x:Name="OrderNumber" />

As above, your XAML becomes much simpler, and leaves you to focus on getting the job done. I wish I'd found a framework like this earlier before I started churning out lots of my own ViewModelBase classes, ViewLocaters etc.

Steve
  • 2,073
  • 4
  • 27
  • 39
3

I also suggest Sacha Barber's blog and all its WPF related articles in codeproject. This guy rocks!

Simone
  • 11,655
  • 1
  • 30
  • 43
  • 2
    Yes, +1 (tomorrow, sorry): I've stared in WPF with his "WPF: A Beginner's Guide" (http://www.codeproject.com/KB/WPF/BeginWPF1.aspx, 2, 3, 4, 5...) – Pascal Qyy Nov 17 '10 at 08:01
3

The most important thing a Winforms/C# developer should know/accept is that WPF is very different from winforms and Winforms way of doing things is not the correct way of doing things in WPF.

I have seen a lot of WinForms developers using events/delegates and threads to solve every each and every problem instead of using Binding, commands, triggers etc.

akjoshi
  • 15,374
  • 13
  • 103
  • 121