Tuesday, December 9, 2008

Composite WPF Guidance – Part 5 (View Layout)

In CAL views from different modules are laid out using two approaches:
  • View Injection
  • View Discovery
In View Injection the application contains a registry of reserved locations called Regions. A module can access regions in this registry using a Region Manger service and use it to inject views. The view being injected does not have any specific knowledge of how it will be displayed in that location. The place it is being injected is referred by a unique name. Each of the objects in the registry implements a specific interface that is used to inject the view. Below given figure illustrates the View Injection approach to dynamic layout.

In View Discovery the modules register their views (or presenters) in a central location, such as in the container, using a well-known interface. In CAL each module constructor accepts an instance of IUnityContainer which can be used to register presenters using the IUnityContainer RegisterType() where TTo : TFrom method. A shell service or a composite view then queries the container to discover the views that were registered.

No comments: