Loading and unloading modules on demand

Topics: Prism v2 - WPF 4
Jun 27, 2010 at 8:12 PM


I'm trying to implement the module loading/unloading in an application that uses Ribbon. When the user selects the tab I fire an event and would like to unload the module that was loaded and load a new one using the RegionManager. But I don't really know how to start it. Does anyone have any suggestions/tutorials/samples that may help? I tried to follow an approach described here but got it all wrong.

Thanks for any help.


Jun 29, 2010 at 10:40 PM
Edited Jun 29, 2010 at 10:40 PM


In Prism there is the possibility to load modules on demand, as explained here. But once modules have been loaded it is not possible to unload/reload them. For more information, you can take a look at this forum thread 

That said, I think that a possible approach for your requirement is to manipulate views at runtime. Using the RegionManager you can add, remove, active, etc views from regions. For more information you could check “view discovery” here.  If you consider View Discovery useful for your application you could check the UIComposition quickstart here or you can download a more advanced sample from here.

Additionally, assuming that your ribbon is on a separated module, you could consider to use Event Aggregation for the communication between the modules. Also this is something demonstrated in the View Discovery advanced sample.

Please let me know if this helps.

Fernando Antivero

Jun 30, 2010 at 6:45 AM

Hi fantivero,

thanks a lot for answering. No, the Ribbon tabs are not a seraparate module, they are a part of a shell. It is because of the poor integration of prism and ribbon that I decided to do it like that. I will try this approach with manipulating the views.