‘Silverlight unleashed’: How to use ViewModelLocator with multiple MVVM assemblies?

I'm just reading your book "Silverlight unleashed".
In Chapter 20 your are explaining how to use MEF to load plugins and how to use your messenger class. But you are not explaining how to load plugins, which where build with the MVVM light toolkit.

It would be interesting to know how to use MVVM in your BingTextSearch and BingImageSearch plugins and how to handle the plugins via MEF and a global (or local) ViewModelLocator.
If I put View and Viewmodel in separated plugins/assemblies where do I instantiate the ViewModelLocator. Usually I put to it in the App.xaml file of the StartUp project.<Application.Resources><Mvvm:ViewModelLocator x:Key="Locator" /></Application.Resources>But I also need a reference in the view
DataContext="{Binding Source={DynamicResource Locator}, Path=PersonVm}"So I need also a reference in the plugin to the ViewModelLocator. And the ViewModelLocator need a reference to the different viewmodels.
But then I have no decupled plugins.

I like your book, but you ignore MVVM in the chapter 20 (Building Extensible and Maintanable Applications) completely and put all code in the codebehind file.
Ok, I don’t want to discuss if it’s ok to use the codebehind file, but I think at this point you were a little bit to lazy. ;-)

But maybe it is not a good idea to use MEF and MVVM light to seperate MVVM parts in different assemblies.
Should I use bigger frameworks like Prism?

As there was no reply here and I am facing exactly the same question I am beginning to wonder if I should be using a different framework too. ;-)

So, a quick last stab, as I actually would prefer to stay with MVVMLight, is it possible to use the toolkit in multiple assemblies, i.e. the View in one assembly and the ViewModel in the main application.

ViewModelLocator (VML) is a good way to expose viewmodels when these are static. For dyanmically loaded objects (such as those loaded through MEF), the VML is more difficult to use. There are a few possibilities:

Bind the dynamically loaded VMs to the DataContext of the view in code. The blendability can then be reached with the d:DataContext design time construct, as explained in http://www.galasoft.ch/mvvmvideo2

If the loaded component is in its own XAP file, use a design time VML in this XAP file (placed in App.xaml of this particular XAP file). This will be available at design time in Blend, but not at run time when the XAP is loaded through MEF into the application.
In this case, assign the VM dynamically to the DataContext (like before).

Create the secondary VML and save it in the application's resources dynamically when the component is loaded through MEF.

I am trying to accomplish the same thing, Mark. Basically I am trying to create a SLOOB that rotates a number of charts in a loop. Each chart will be it's own View and have it's own ViewModel to acquire it's data. I'm thinking that I'll use the Telerik transisition
control on the MainPage.xaml and use the ViewModelLocator to discover and dyanmically load each view. But I am not at all sure how to do that.