Search code examples
prismmef

Prism: Nested Regions


I googled a lot but i didn't find an exact answer. I'm using Prism-Mef, i have RegionB which is nested inside RegionA When i declare:

IRegion regionB= regionManager.Regions[RegionNames.RegionB];

i got the exception:

The region manager does not contain the RegionB region.
  • 1-How i can access RegionB to Add view to it, knowing that i will use it as a scoped region.

  • 2-If i have a third level of nesting: for example RegionC which is nested inside RegionB, how can use RegionC to add a View

Thanks in advance.


Solution

  • Assuming you created a scoped RegionManager - you need to use the scoped region manager of the view that contains the inner region.

    var scopedRegionManager = RegionManager.GetRegionManager(view);
    var regionB = scopedRegionManager.Regions[RegionNames.RegionB];