I’m reading through the Prism v2 guidelines in which they state:
During initialization, modules use the RegionManager to locate regions in the shell and add one or more views to those regions or register one or more view types to be created within those regions
I understand that views are added in the bootstrapper e.g. in the GetModuleCatalog() method:
protected override IModuleCatalog GetModuleCatalog() { ModuleCatalog catalog = new ModuleCatalog() .AddModule(typeof(HelloWorldModule.HelloWorldModule)); return catalog; }
But what does it mean to register a view type? Why do modules need to ‘register a view type’ with the shell if they are already ‘adding their views’ as with the above code?
In your code you are not adding Views to the bootstrapper but Modules to the ModuleCatalog. A Module in the CAB/Prism/Composite UI world can contain Views, but many times it provides some sort of add-on service that other Modules can use. For example, let’s say I have a Shell that happens to uses some docking manager to display views. I want modules to use an API IDockingWindowService to show/hide window. I want the service implementation to be easily interchangeable so I create a Module that contains a service called DockingWindowService and implements IDockingWindowService. I register this Module with the ModuleCatalog.
The composite framework workflow would create this service, registers it with the bootstrapper and any modules loaded after this fact would be able to use the IDockingWindowService. This service is not a view, but logic; just wanted to point out that distinction. That being said, a Module can contain 0 or more Views (or, as a simplification, UserControls). The unit of UI is the View. A Module is more of a logic and/or UI bundling concept.
Back to your particular question: What the documentation is saying is that if you use Regions to display your Views, you can register the View types with the Region. Whenever the Region is shown, it will automatically build the View using the Unity container.