This project has moved and is read-only. For the latest updates, please go here.

Sample code in ViewModelLocater

Jun 18, 2012 at 3:37 PM

Hi Laurent,

Uncommenting the sample code in the constructor of the ViewModelLocator that registers dataservices (and setting up the appropriate bindings / app.xaml change) causes an exception in the designer when viewing mainpage.xaml. This is because for the ViewModelLocater is created twice and the SimpleIoc.Register calls are made twice. It would be useful if uncommenting this code led to a usable application.

A simple workaround is to make the sample constructor of ViewModelLocator into a static constructor instead of an instance constructor.

(Note: I'm using MVVM Light with VS 2012 and a Metro UI, I haven't investigated whether this is the same for the earlier stable versions).

Aug 22, 2012 at 12:53 PM

Thanks Joshka!

I was going nuts over this exception in the designer ...

So I can confirm your workaround works also in VS 2010 and MVVMLight v (NuGet today: package id="MvvmLightLibs" version="")