Multiple XAP files

May 27, 2011 at 10:35 AM


Is it possible to divide SL app into multiple XAP files using Simple MVVM toolkit? How?



May 27, 2011 at 2:44 PM

@Mahesh: Yes, splitting XAP files is possible using Managed Extensibility Framework (MEF), which ships as part of .NET 4 and Silverlight 4 and is supported by the Simple MVVM Toolkit.  I explain how to do this in the last part of my webinar on MEF:  There is a recorded video with slides and code samples.  Take a look at these and let me know if you have any questions.



Jul 3, 2011 at 9:58 AM
Edited Jul 4, 2011 at 7:11 AM

I saw the webinar, and i saw what you explain about mef composition, but is it possibile to see how you resolve composition of multiple xap with simple mvvm toolkit. I saw an exemple in light toolkit where it's resolved with a general class with some functions implemented to manage many aspects of import but in all of the solution this class is used to retrieve reference to classes imported/composed.

Jul 3, 2011 at 1:46 PM
Let me work on it. Most examples of XAP splitting with MEF are over complicated. I favor a simpler approach. Check back here in the next couple of days.
Jul 7, 2011 at 6:05 PM

Any news? I hope it's not so hard to integrate discover and load splitted XAP with simple mvvm toolkit, i have an idea of a kind of dashboard in silverlight and i want to develop with simple mvvm. 

Jul 7, 2011 at 9:40 PM

Yes, I found it.  Download the slides and code from my presentation on MEF:

Toward the end of the webinar I give an example of using MEF to split XAP files in order to asynchronously download parts of a Silverlight app on demand.



Jul 7, 2011 at 10:28 PM

Yes, i saw them but i need it's an exmple of integration with your simple mvvm, how can i use mef and xap splitting with your locator or your framework in general?

Jul 8, 2011 at 2:10 PM

Using MEF for extensibility (plugins) is beyond the scope of Simple MVVM Toolkit (and I don't have the time presently to put together a complete sample of that). But the part you're interested in, which is using MEF to split a Silverlight app into more than one XAP file, is fairly straightforward.  If you take a look at the LunchSelector sample app from the webinar, the piece of code you would need to implement can be found in MainPage.xaml.cs.  Instead of placing this in the View's code-behind, all you would have to do is put it into a ViewModel.

public void LoadPlugins()
    // Create a new deployment catalogs for the plugins
    DeploymentCatalog plugin1Catalog = new DeploymentCatalog
    DeploymentCatalog plugin2Catalog = new DeploymentCatalog

    // Add the first plugin

    // Add the second plugin

Hope this at least gets you going in the right direction.