I put together a MVVM tutorial for WPF using Laurent Bugnion’s MVVMLight Toolkit. This tutorial is for beginners (like me!) as I struggled to piece a workable MVVM light application together. There are many tutorials, but some are for Windows Phones or don’t have exactly what we wanted for WPF. I am still wondering why I’m messing around with MVVM, but it seems to be the way to go with WPF .
An IMPORTANT NOTE about the tutorial. I started out very meticulous in piecing it together, but at 1am and rather tired and wondering ‘who’ I was really putting the tutorial together, I accelerated my notes. It is very much usable and ‘all there,’ but not as meticulous as it was at the beginning.
Tutorial 1 – Step by Step WPF Application with MVVMLight is in PDF format mainly because converting the MS Word file to WordPress was excruciating (formatting would not cooperate).
Here is the working SOURCE CODE for Tutorial 1.
Here are some Links, although I’m guessing if you found this you probably found many of the links below:
Laurent’s MVVM Page: http://www.galasoft.ch/mvvm/
Laurent’s blog here: http://blog.galasoft.ch/category/10201.aspx
http://mvvmlight.codeplex.com/
This looks like the same thing on CodeProject. Looks like it was just published… I just found it!
That’s all for my MVVM tutorial for now….
First of all thank you for the tutorial, so far is the only step by step tutorial I have found. Even though the project compiles and works I cannot see the .xaml previews because for some reason the following line of code is showing a warning that reads as follow…
Line of Code which show the warning.
Warning Message:
the name “EventToCommand” does not exist in namespace “clr-namespace:GalaSoft.MvvmLight.Command:assembly=GalaSoft.MvvmLight.Extras.WPF4”.
Any idea what can I do to fix it? Again everything works but I cannot preview the .xaml files.
Line of Code which show the warning.
GalaSoft_MvvmLight_Command:EventToCommand x:Name=”Page2ButtonClicked” Command=”{Binding Page2Command, Mode=OneWay}”
@Fily – Thanks for the message and finding an issue. I copied you on an email to a friend that can answer it better than me.
I don’t know why you can’t preview the XAML files, they should be in one of the folders.
As a side note, this was literally the first start into MVVM so it’s a little rough, but it was a working example at one point. Hopefully, my friend can look at it, he’s kept up w/ the MVVM better than I as I’ve moved onto some other things, which you could see by the blog. I want to get back to this, but no time:-(
Mark
Mark,
Just to clarify one thing, your example project works and compiles fine but for some reason I don’t get a preview of the controls in the .XAML files and I see a squiggly line in the following code line of code GalaSoft_MvvmLight_Command:EventToCommand
Thanks a lot for your help.
Hi Fily,
See
https://blogs.msdn.microsoft.com/brada/2009/12/11/visual-studio-project-sample-loading-error-assembly-could-not-be-loaded-and-will-be-ignored-could-not-load-file-or-assembly-or-one-of-its-dependencies-operation-is-not-supported-exception-from/
Hi Fily
Check this link, it helped me:
http://stackoverflow.com/questions/26343678/where-do-i-find-galasoft-mvvmlight-wpf45-assembly
Hi, for those who are having errors ng xaml, these are the correct namespace as of now.
xmlns:GalaSoft_MvvmLight_Command=”clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform”
xmlns:Custom=”http://schemas.microsoft.com/expression/2010/interactivity”