With the help of my dear workmate Julian Dominguez, I’ve been developing a new region adapter: the WindowRegionAdapter. It provides a way to show views in separate windows and has the following features to take into account:
- It uses a SingleActiveRegion, so that only one (or no) view (one window) is active at a time.
- It provides a WindowStyle property (of type Style) which allows the developer to specify a custom style to use as a template for all the windows shown in the region.
How to use the WindowRegionAdapter
Step 1 - Register the adapter mapping
The first thing you will need to do is to register the mapping for the Region Adapter for the type Window. To accomplish this, you must override the ConfigureRegionAdapterMappings() method of the Bootstrapper, retrieving the RegionAdapterMappings from the container, and calling its RegisterMapping() method, sending the Window type and a new instance of the WindowRegionAdapter, as follows:
protected override RegionAdapterMappings ConfigureRegionAdapterMappings()
{
RegionAdapterMappings regionAdapterMappings = Container.TryResolve<RegionAdapterMappings>();
if (regionAdapterMappings != null)
{
regionAdapterMappings.RegisterMapping(typeof(Window), new WindowRegionAdapter());
}
return base.ConfigureRegionAdapterMappings();
}
[Recommended]: Alternatively, you may provide a custom style to use as template for all the windows shown in the region by setting its WindowStyle property on initialization (as shown in the sample application):
regionAdapterMappings.RegisterMapping(typeof(Window), new WindowRegionAdapter() { WindowStyle = (Style)Application.Current.FindResource(“WindowTemplate”) });
Step 2 - Set the owner for the child windows
To use the WindowRegionAdapter, you must add the cal:RegionManager.RegionName attribute to a Window (for example, the Shell window), as follows:
<Window x:Class=”Example.Shell”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
xmlns:cal=”http://www.codeplex.com/CompositeWPF”
Title=”MainWindow” Height=”400″ Width=”500″ WindowStartupLocation=”CenterScreen” cal:RegionManager.RegionName=”MyWindowRegion”>
The WindowRegionAdapter will get this window and will use it to set the value of the Owner property of each child window to this window.
Screenshots

Figure 1. View at design time.

Figure 2. View displayed in a new window (by the Window Region Adapter) at run time.

Figure 3. The sample application running with several views displayed.
Disclaimer
This code is provided “AS IS” with no warranties. You can use it freely. It includes the binaries of Composite Application Library and Unity Application Block.
Download the WRAExample sample application here!
EDITED 10/26/2008: Now, it’s available at CompositeWPF Contrib! Get the latest change set here!
Enjoy!
As always, any feedback is welcome!
Related posts:
Cheers!
Nacho