Modules Coupled to Regions

May 11, 2010 at 12:33 PM
Edited May 12, 2010 at 1:38 AM
Why are modules coupled to Regions in the Shell? Why not allow the shell to inject the region into the module? It seems to me that the a module must define it's region by name and this seems backwards as a module should not at all care which region it is used in. I understand that the shell can bind to the name of the region defined in the module but this seems like extra work when the region can be injected into the module by the shell which also decouples the module from the shell. Is there any way to do accomplish this? For example, in some module: public void Initialize() { regionViewRegistry.RegisterViewWithRegion("MainRegion", typeof(Views.View1)); } --- Why does/should the module care what the named region is is going to be viewed in? Why not something like public void Initialize(Region region) { regionViewRegistry.RegisterViewWithRegion(region, typeof(Views.View1)); } or something similar?
May 12, 2010 at 7:08 PM


Before going into the core of the question, please note that modules aren’t added into regions. This is because modules are not part of the user interface. They might contain views, which compose the UI, and those are the ones that can be added to regions. You can find more detailed explanations of that difference in these threads:

As for the question itself, you can find an explanation of why the module is in charge of the UI composition in this thread, along with an explanation of other possible approaches, and their pros and cons.

I hope you find this helpful.

Guido Leandro Maliandi