Prism & MEF - View Management

Jan 18, 2011 at 2:41 AM

MEF exercise 3 discusses the OnDemand remote loading of a view (ModuleBView) through an IModule implementation of an associated class: (ModuleB).  But, as far as I can gather, in order for this technique to work, each view (ModuleXView) must be in it's own project with the associated module (ModuleX: IModule) since, in order to show the View, one must call IModuleManager.Load(ModuleX).  Every view in that project that is decorated with [ViewExport] will then be shown in the appropriate Region.  Call me crazy, but I don't think that it's efficient to create a separate project for every view.  Am I missing something here?


Jan 27, 2011 at 4:45 PM


The modular application development approach is useful to divide the units of functionality within your application into separate, loosely coupled components that are located in different assemblies. The approach described in the excercise you've mentioned shows how to load modules on demand, not just views. That is to say, modules can contain both services and views that are related to the functionality the module exposes.

If you had, for example, an application with views that are all related to the same piece of functionality, you should place those views inside the same module (and therefore, inside the same project), but if you had an application with different modules that could have been developed by different teams, it can be useful to encapsulate the logic for each piece of functionality in a separate discrete module. From the Modular Application Development chapter of the Prism documentation:

"The modular application approach, on the other hand, can help you to identify the large scale functional areas of your application and allow you to develop and test that functionality independently. This can make development and testing easier, but it can also make your application more flexible and easier to extend in the future. The benefit of the modular approach is that it can make your overall application architecture more flexible and maintainable because it allows you to break your application into manageable pieces. Each piece encapsulates specific functionality, and each piece is integrated through clear but loosely coupled communication channels."

I hope you find this helpful.

Guido Leandro Maliandi

Marked as answer by dschenkelman on 10/3/2013 at 11:50 AM