28

I've got about three years c# experience. I'd like to learn some WPF and the MVVM pattern. There are a lot of links to articles on this site but I'm getting a little overwhelmed. Would a sensible approach for a begginer to be forget mvvm for a while and just quickly learn a bit a of WPF, then come back to MVVM?

I had a leaf through Application=Code+Markup - Charles Petzold in work today, it doesn't seem to mention MVVM (at least not in the index). I was pretty surprised by this as I thought MVVM was supposed to be the "lingua franca" of WPF?

Also I've just started working at a new company and they are using MVVM with WinForms, has anyone come across this before?

Can anyone recommend a book that will teach me both WPF and MVVM?

Gishu
  • 134,492
  • 47
  • 225
  • 308
handles
  • 7,639
  • 17
  • 63
  • 85
  • The MVVM pattern is a popular approach for simplifying and detangling WPF applications, but it's not the only one. I've found that TMTOWTDI (there's more than one way to do it) definitely applies to WPF. – dthrasher May 06 '10 at 20:22
  • This book is exactly what you need: "Learn WPF MVVM" https://www.amazon.com/dp/B01M365NCZ It teaches you WPF in no time, and then introduces you to MVVM. Disclaimer: it's my book. :-) Good luck on your learning! – Arnaud Weil Sep 06 '17 at 15:18

8 Answers8

29

It depends on your experience.

I personally felt that this was a lacking area in MVVM discussions, which was what led me to write my series on MVVM and WPF from a Windows Forms developer perspective.

I would not try to learn WPF without learning MVVM. You'll end up trying to "unlearn" many aspects, as WPF really doesn't make sense, completely, until you understand the separation of presentation and logic that's pervasive throughout the architecture. MVVM is really just extending this same separation into the application space.

As for "MVVM in Windows Forms" - a lot of people try to do this, but it's not really MVVM. In order to do "MVVM" you need access to a richer form of data binding than Windows Forms provides. "MVVM in Windows Forms" is really, typically, just Model-View-Presenter with a different name (riding the MVVM bandwagon, I'd guess), but not really the same as MVVM in WPF.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • WPF without MVVM is bewildering and frustrating. WPF with MVVM is liberating and exciting. – Robert Rossney Mar 29 '10 at 23:15
  • WPF really requires some form of separation of concerns or it just doesn't make sense... – Reed Copsey Mar 29 '10 at 23:17
  • Thanks for the series, I've been looking for decent Winforms->WPF information. – Paolo Jun 03 '10 at 08:11
  • 2
    After reading a lot of useless info on MVVM, where everybody spoke about MVVM in an uncomprehensible theoretical way, your tutorial began to make light on my head. Thank you. – sergiol Jun 17 '11 at 09:03
  • @ReedCopsey Do you have some kind of published version of your posted series? Its the kind of thing I think I would love to have as an offline reference library – eatumup Oct 14 '16 at 23:58
  • @eatumup No - but you're welcome to print them if you want. – Reed Copsey Oct 14 '16 at 23:59
13

Jason Dolinger has an excellent video on the subject. It steps you through the process moving from using code behind files to a full MVVM pattern including Dependency Injection and Testing.

Bill Steele did a 16 part "Soup-to-Nuts" webcast series on WPF. The links on the msevents site are broken. Here is a Google search to find them. This will help with the WPF learning curve. And he does NOT use any MV* patterns in his examples.

EDIT: The MSEvents links are working now, I am leaving the Google search as a backup.

Josh Smith also has an excellent article WPF Apps With The Model-View-ViewModel Design Pattern on MSDN.

Herding Code: Presentation Patterns with Jeremy Miller, Ward Bell, Rob Eisenberg and Glenn Block

MIX10:

And of course Reed Copsey's MVVM articles are worth a read as well.

VoidDweller
  • 1,858
  • 13
  • 17
6

I was told a few times that my MIX10 session was explaining the MVVM pattern well enough for beginners (even though some parts are actually quite advanced, so don't worry if you need to re-watch certain parts).

The session is at http://live.visitmix.com/MIX10/Sessions/EX14

Sorry for the self-promotion.

Cheers, Laurent

LBugnion
  • 6,672
  • 2
  • 24
  • 28
  • @Laurent: I missed that self-promotion before I added your session to my answer. :) – VoidDweller Apr 01 '10 at 05:19
  • +1 I found your techdays video on mvvm very helpful! =) http://channel9.msdn.com/Blogs/kreekman/TechDays-2010-Understanding-the-Model-View-ViewModel-pattern – gideon Feb 19 '11 at 04:32
4

There aren't many books covering MVVM but there is one : Advanced MVVM

But there are lots of online resources and this one is a must read : WPF Apps With The Model-View-ViewModel Design Pattern

After that I suggest looking into frameworks like

Catalin DICU
  • 4,610
  • 5
  • 34
  • 47
  • 2
    +1 when playing with WPF and MVVM last weekend, I almost immediately ran into the limitation that I couldn't bind event handlers to the viewmodel. The frameworks you link to appear to fix that, so I'll definitely be checking them out! – Wim Coenen Mar 29 '10 at 23:20
2

To do big things (like learning WPF + MVVM) it is better to break the task in smaller steps.

I think that the best approach in this situation is to start by learning the UI part of Wpf. Learn XAML syntax, the layout system, the available controls and forget about binding and how to deliver data to the controls.

Once you know the UI basics of Wpf then it is time to move to MVVM. Learn how bindings work and the MVVM pattern.

In this Web you can find a tutorial focusing on the hands on but with the theory available:

http://www.learnmvvm.com

Ignacio Soler Garcia
  • 21,122
  • 31
  • 128
  • 207
1

Here is a tutorial for MVVM http://www.codeproject.com/Articles/819294/Learn-WPF-MVVM-step-by-step-Basics-to-Advance-Leve which goes from basic to the advance level in 5 steps. So its like graduating from a 3 layer to full MVVM.

enter image description here

Shivprasad Koirala
  • 27,644
  • 7
  • 84
  • 73
0

Try this site. It collects the various resources at one place. http://learnandmasterwpf.blogspot.com/

0

I just read this book. It is not really about learning WPF, but it should be useful once you already know a bit of WPF and want to progress your understanding of MVVM.

http://www.amazon.co.uk/Pro-WPF-Silverlight-MVVM-Model-View-ViewModel/dp/1430231629

Ashley Davis
  • 9,896
  • 7
  • 69
  • 87