Regions

Regions in PRISM

Regions are logical placeholders defined in the Application's UI into which views are displayed. There are some controls that can be used as a region:

  • ContentControl.

  • ItemsControl.

  • ListBox.

  • TabControl.

You can display a view programmatically or automatically. In addition, Prism provides a navigation system with regions. You can locate a region through the RegionManager component, using the RegionAdapter and RegionBehavior to coordinate the display of views within specify regions.

<ContentControl x:Name="regionNameExample" Visibility="Collapsed" Regions:RegionManager.RegionName="SetRegionNameExample"/>

In the example above, you can see how to assign a region named "SetRegionNameExample" in the ContentControl Component. Therefore, you can display a view into the ContentControl.

Sample of UI with Regions. Take it from Silverlight Documentation

Region supports in Angular

There are no direct equivalent concepts in Angular for converting PRISM regions.

This means that the framework must provide its own replacement for the region support. This means that the framework needs to create classes for:

  • RegionManager

  • Region

  • Region attached properties

  • RegionAdapters

  • etc.

The final goal is to have concepts that are easily converted using the conversion tool.

The regionName directive in Angular

To mimic Silverlight's functionality with the attached property RegionName, Angular provides the directive concept, it allows us to code a behavior like the original.

Given the following XAML code:

The conversion tool will generate this code:

Notice that, in this case wm-content-control (the current conversion of ContentControl) does not have a regionName property. This property is defined as an Angular attribute directive:

Notice that this code uses setValue method which in turn requires the definition of a property:

Later regions are adapted when a view is added to a region:

There is an adapter for each control. By default, the Framework generates and registers adapters for:

  • TabControls.

  • TabItems.

  • ContentControl.

  • SelectorControl.

  • ItemsControl.

The adapter is the way to configure a control a tell it how to handle the view/views.

For the content-control is:

In this case, the code registers a handler for the ActiveViews collection, when the collection changes, it will take the first or default view and set the value to the content property of the ContentControl.

The next image shows all the sequence that the region directive runs to display a view into a region in the ItemsControl component.

RegionName Directive sequence

Last updated

Was this helpful?