views:

654

answers:

1

I have a Silverlight Prism application that includes a toolbar module with login controls. I currently have a module in the main region set to InitializationMode.OnDemand in the Bootstrapper and can load it via ModuleManager.LoadModule() after a successful login in the toolbar module. However, this doesn't feel right as it's essentially tightly coupling the toolbar module to the module(s) it loads after login.

Now for the question... Is this best practice, or should I pursue something along the lines of raising a CompositePresentationEvent from the toolbar module and having the shell load the appropriate modules? Or are there other options? I'm building this application in an attempt to learn more about Prism and I want to be sure I'm following best practices as much as possible.

A: 

I like the EventAggregator approach in this case better. I don't like one module knowing about the other. At most, the Shell should have an awareness of the other modules, but they shouldn't cross-talk like that.

Since this is more of a shell responsibility, have you considered baking this into the Shell itself? If they are logically the same, there's not much reason to keep them separate unless you intend to replace your toolbar often. I generally bake menus into the shell and make a way for Modules to contribute to the menu through a service like IMenuRegistry or something like that. Just a suggestion.

Anderson Imes
Plenty to consider here. Thanks for taking the time to answer. I don't expect to replace the toolbar often (if ever), but I haven't gotten into the EventAggregator much yet, so I may go that route to learn more about it.
Andrew Dyer