Confirmation of understanding

Topics: Prism v1, Prism v2 - WPF 3.5
Jun 17, 2009 at 4:52 PM

I am in a situation where I am trying to understand if a module can/is loaded multiple times or if it is loaded once and only once.  Reason being is I need to have what the user will interpret as multiple instances of a module being loaded, each instance would be in a unique data context.  From what I have read, I am under the impression that the module is initialized once, which means no multiple instance of module but the core main view is to be loaded multiple times, each with its' own LocalRegionManager and session manager to handle transactions for the database.

Is this correct, or if I am off where am I off and where can I go to get a clearer understanding of this situation.

Jun 17, 2009 at 7:18 PM

Hi Don,


You are under the correct impression. Prism modules are usually loaded once per application. The user does not have any notion of what a module is, but he does notice views (UI components). Thus, if you want the user to feel he has more than one “use case” (assuming there is one per module, this is just an example) of the same type running, you could create multiple instances of the views you require from that module, each with its own Presenter (can also be ViewModel or Controller) and show them in regions. Also, if there is not a ScopedRegion, all regions will be under the same region manager.


To handle transactions from the database, there is no need to create individual instances for each view. Having a common service, which the views presenter can perform requests to and obtain your data.


As an example of the above, you could have different instances of CustomerView in a single TabControl (which would be a region).


When you load a module, you “get access” to all its functionality. You can use it as many times as you want, depending on your application needs.


The following documents from the Prism-v2 documentation might provide some more insight to the topics I mentioned above:

·         Modularity

·         Module

·         Shell and View

·         UI Composition


Please let me know if this helps.


Damian Schenkelman

Jun 17, 2009 at 9:03 PM

Yes this does help.  I have a clearer understanding on how the framework is defined and what addition I need to add to my application to handle the appearance of multiple instances.  So what I will have designed is a module that has:

  • Service that is responsible for my data communications
  • Controller that has atleast one method to generate an instance of my main view (visual usecase)
  • Views

So when the module is initailized it just registers the types needed (Views, Services, Controllers, etc...) and when I fire off the command to load an instance of set use case for an item, it will fire off that controller to create a new instance of that main view under that loaded data context of item.