1
votes

I am new to prism with windsor container and windsorboot strapper. I am trying to register my region in my shell and trying to add a view to that region from my module project which is a class liberary. But I am getting the following excption from my module class while initialization:

"This RegionManager does not contain a Region with the name 'MainRegion'. Parameter name: regionName"

Moreover bellow is the code I am writing for my region in shell and for registering the view.

Shell Xaml for creating region.

xmlns:Regions="clr-namespace:Microsoft.Practices.Prism.Regions;assembly=Microsoft.Practices.Prism" 

<ContentControl x:Name="MainRegion"
 Regions:RegionManager.RegionName="MainRegion"/>

Registering view in Module.cs class while initialization of module:

regionManager.AddToRegion("MainRegion", container.Resolve<myview>());

Can any one suggest me why I am not receiving my regions in module where as container wise I am using windsorcontainer. Thaks.

Raza

1

1 Answers

5
votes

Most probably it is because the view that contains the region is not shown yet. The region gets registered with the RegionManager only when the view that contains the region is loaded.

To solve this, instead of calling AddToRegion, call RegisterViewWithRegion that takes a delegate for getting the view:

regionManager.RegisterViewWithRegion("MainRegion", () => container.Resolve());