UIComposition Quickstart... why HeaderPanel vs RegionName

Oct 23, 2008 at 1:22 AM
In the UComposition Quickstart, the EmployeesView defines a Named ContentControl (HeaderPanel) and sets the Content explicitly.  Why is this done versus using a Region?
Oct 23, 2008 at 4:28 PM

Hi

 

As you said, the EmployeesView of the UI Composition Quickstart contains a ContentControl called HeaderPanel that is not marked as a region and its Content is explicitly set in the EmployeesPresenter:

<StackPanel>

<ContentControl x:Name="HeaderPanel"/>

<ContentControl cal:RegionManager.RegionName="{x:Static local:RegionNames.DetailsRegion}"/>

</StackPanel>

 

The reason of this approach is that the content of the HeaderPanel control does not need to be changed (it will always contain the same employees’ list), so you do not need to expose it as a region.  

The other ContentControl is marked as a region because its content will be changed at runtime with views that belong to different modules (the UIComposition.Modules.Project and UIComposition.Modules.Employees).

 

A region is usually used when you want to dynamically add or remove views to a known location in the application without being tightly coupled to the containing view (because you can access to them only by knowing their names). Regions are specially useful when the views that you want to show are placed in different modules because enable a compositional pattern.

 

In this case, the EmployeesView would not make sense if the list of employees is not set, so the EmployeesView pulls the view into that placeholder, as opposed to the view being pushed by a different controller into a region, where the EmployeesView would not have control on whether the view was actually placed inside it or not, and would have to use decoupled (therefore more complex) means for communication with that view, when this is not really necessary.

 

For more information related to regions you can check the following article:

·         Regions

·         UI Composition QuickStart

                                                                                                                                                                                                                                                        

Please let me know if this helps.

 

Mariano Converti

http://blogs.southworks.net/mconverti
Oct 23, 2008 at 4:48 PM
Great explaination.  I did not see the UI Composition QuickStart article which clearly states the answer to my question.  Thank you.