Window Region Adapter

The WindowRegionAdapter provides a way to show views in separate windows with a custom style:

Important Features

  • 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

  • 1 - Register the adapter mapping for the Region Adapter for the type Window:
protected override RegionAdapterMappings ConfigureRegionAdapterMappings() 
    RegionAdapterMappings regionAdapterMappings = Container.TryResolve<RegionAdapterMappings>();
    if (regionAdapterMappings != null) 
        regionAdapterMappings.RegisterMapping(typeof(Window), new WindowRegionAdapter()); 
    return base.ConfigureRegionAdapterMappings(); 

Recommended: Provide a custom style to use as template for all the windows shown in the region by setting its WindowStyle property on initialization:
regionAdapterMappings.RegisterMapping(typeof(Window), new WindowRegionAdapter() { WindowStyle = (Style 
Application.Current.FindResource("WindowTemplate") });
  • 2 - Add the cal:RegionManager.RegionName attribute to a Window (for example, the Shell window) to set the owner for the child windows, as follows:
<Window x:Class="Example.Shell" 
Title="MainWindow" Height="400" Width="500" WindowStartupLocation="CenterScreen" 
  • 3 - Display a view as follows:
MyViewPresenter myViewPresenter = myContainer.Resolve<MyViewPresenter>();

More Information

For more information and a sample application, you may visit WindowRegionAdapter for CompositeWPF (Prism).

Last edited Oct 26, 2008 at 5:44 PM by ejadib, version 2


No comments yet.