This project has moved. For the latest updates, please go here.

Suggestion for ViewModelLocator template modification

Nov 4, 2012 at 6:45 PM
Edited Nov 4, 2012 at 6:47 PM

Hi Laurent,


I admire your work greatly and I was wondering if you could consider this changes in the ViewModelLocator template.

This is the Static Constructor of ViewModelLocator class:

        static ViewModelLocator()
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

            if (ViewModelBase.IsInDesignModeStatic)
                if (SimpleIoc.Default.IsRegistered<IDataService>())
                SimpleIoc.Default.Register<IDataService, Design.DesignDataService>();
                SimpleIoc.Default.Register<IDataService, DataService>();


The reason is if you put the Interface to a different assembly it tries to register the sane static instance every time when the xaml designer is open and you hit F6.
Hopefully my explanation is clear enough but if it isn't let me know and I'll send you a detailed one.

Thank you

Best Regards,

Nov 5, 2012 at 6:41 PM

I've made StepsRecord to easily reproduce the error and the solution. You can download it from here.