0
votes

I'm very new to modules in Prism and am struggling to understand how to use them properly. I want to have a navigation panel like in the image below, which I stole from Google.

enter image description here

Let's say that I have 3 modules for 3 separate concerns: NavigationModule, HelpModule, and FeedbackModule. If I want to show "Help" when the app first loads, my understanding is that I would do something like the following:

  1. Define Regions for navigation and content in my Shell (main WPF project)
  2. Upon execution, load the navigation view into the navigation Region
  3. Upon initialization of the NavigationModule, load a view from HelpModule into the main content Region

This leaves me with a few questions about what modules should know about each other:

  1. Should the Shell's project have a reference to the NavigationModule in order to load its view?
  2. Should the NavigationModule have a reference to the HelpModule in order to load its view? And a reference to FeedbackModule in order to load its views on demand?

If the answer to these questions is "no," then what's the best way for modules to be aware of each other's views? I could create a shared class library with constants for view names, but it seems a bit troublesome to maintain a bunch of strings that way whereas with references I could use nameof(). I would appreciate any direction. Thanks.

1

1 Answers

2
votes

Modules should not "know" each other in the sense of having a project reference from one module to another, because that kind of defeats anything gained from having modules in the first place, that is, to have a modular application (built of components that can be swapped out independent of each other).

Modules should interact through shared interfaces, which are define outside of modules, that is either in the framework or in assemblies that "are" no modules themselves. Depending on your requirements, you should define upfront (and enforce in the build process) which modules there are and which interface-assemblies and which module is allowed to reference which interface-assembly.

So how to show the Help-view when the application loads? Send a message (e.g. via IEventAggregator or any other communication mechanism) when it's time to load the initial view (whatever that may be). The Help-module listens for the message and navigates to the Help-view. Important: the SessionResume-module might also listen for our message. It's the responsibility of whomever choses which modules to deploy to only deploy modules that are compatible with each other.