DataBinding a Region

Mar 9, 2010 at 12:00 AM

I have a carousel that I want to put modules into.

I want to set in each carousel item (which is a datatemplate) a region bound to the viewmodel.

I have the following:

<ItemsControl x:Name="Region"
                       Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                       Regions:RegionManager.RegionName="{Binding Region}">


Region is a string where I give the region a name.


I have tested this and get the following error on load:

The region manager does not contain the LayoutReportInteractionRegion region.


I have ensured that the parent region that houses the carousel is loaded first in the bootstapper:

ModuleCatalog catalog = new ModuleCatalog()
                .AddModule(typeof(PMSDash.LayoutReportInteraction.LayoutReportInteraction), new string[] {"ReportLayoutSelector"});


Bellow is the offending module that cannot load:

public class LayoutReportInteraction : IModule
        public IRegionManager regionManager { get; private set; }
        public IUnityContainer container { get; private set; }

        public LayoutReportInteraction(IUnityContainer container, IRegionManager regionManager)
            this.container = container;
            this.regionManager = regionManager;

        public void Initialize()
            var addView = this.container.Resolve<LayoutReportInteractionMain>();





does anyone have any ideas on the issue or a better way to go about this?




Mar 12, 2010 at 3:16 PM

Hi Nick,

The exception probably happens because at the moment you are trying to add a view to the “LayoutReportInteractionRegion”, it doesn’t exist in the RegionManager. When debugging the application you can check the different regions in the RegionManager to validate which ones have already been created. 

The UI Composition quickstarts provide sample code on how to compose the UI with different views, so you might find some of the samples there useful.

You can also try using view discovery instead of view injection, if the cause of your problem is timing (that is, if the region is created after the view).

If the aforementioned suggestions do not help, it would be useful if you could provide a repro sample, so we can help you solve this issue.

I hope you find this helpful.

Guido Leandro Maliandi