12

I'm trying to learn MVVM Light and am looking for a good basic example that shows a model and how to load different views.

The template I see after downloading MVVM Light has no models and only one view. (http://www.galasoft.ch/mvvm/creating/)

Other things I've found are more complex and a bit confusing when all I want to see are the basics.

Thanks.

BillyPilgrim
  • 541
  • 3
  • 13
  • 25

4 Answers4

9

I have found this example helpful:

http://apuntanotas.codeplex.com/

Bill
  • 1,407
  • 1
  • 15
  • 22
  • 2
    The "model" in this example implements INotify. I tend to think of the Model as using POCOs (Plain Old CLR Object) and with the ModelView implementing the INotify to allow data binding. – Chris Bennet Feb 26 '16 at 16:35
  • 1
    This answer is no longer helpful to man or beast because the link includes no code or any useful information whatsoever – Ortund Jul 18 '18 at 11:17
  • As of July 2020, there's a big "download archive" link at the top of the page - click there, go to sourceCode/sourceCode.zip. You're welcome. – rsenna Jul 10 '20 at 12:04
1

I have personally found these to be quite useful, though they also use MEF and RIA Services which can complicate things:

A Sample Silverlight 4 Application Using MEF, MVVM, and WCF RIA Services

Architecting Silverlight 4 with RIA Services MEF and MVVM - Part 1

In April, the author of the MVVM Light toolkit said that he would eventually be creating a reference application in both Silverlight and WPF. (Source)

You might find these other questions useful:

mvvm light toolkit samples

wpf/silverlight mvvm sample app request

mvvm tutorial from start to finish

Community
  • 1
  • 1
kevev22
  • 3,737
  • 21
  • 32
1

I found these two to be very helpful:

http://www.codeproject.com/KB/WPF/blendable_locator.aspx http://rickrat.wordpress.com/2011/01/24/using-mef-to-link-view-model-locator-and-load-assembly-uis-dynamically

The first one is just a simple drop-in viewModelLocator class for MVVM Light that gives you the MEF abilities.

[ExportViewModel("Demo1", false)]
class Demo1ViewModel : ViewModel
{   
}

And the second one, uses the same approach with an additional MefHelper class that enables run time loading of MEF components.

public void Compose()
{
AggregateCatalog Catalog = new AggregateCatalog();
// Add This assembly's catalog parts
System.Reflection.Assembly ass = System.Reflection.Assembly.GetEntryAssembly();
Catalog.Catalogs.Add(new AssemblyCatalog(ass));

// Directory of catalog parts
if (System.IO.Directory.Exists(ExtensionsPath))
{
    Catalog.Catalogs.Add(new DirectoryCatalog(ExtensionsPath));
    string[] folders = System.IO.Directory.GetDirectories(ExtensionsPath);

    foreach (string folder in folders)
    {
        Catalog.Catalogs.Add(new DirectoryCatalog(folder));
    }

}

_Container = new CompositionContainer(Catalog);
}
kgrandpak
  • 48
  • 7
0

I found the following tutorials to be a quick and easy way to get started:

MVVM Light Toolkit Example

MVVM Step By Step

Eternal21
  • 4,190
  • 2
  • 48
  • 63