Cannot find Region in RegionManager (using PRISM)

I am writing an application in Prism. I have a user control and contains two <ContentControl> controls. They both have Regions assigned to them. The user control is placed in the Window , which is displayed using ShowDialog() .
I add one of my views to the region using discovery discovery, and the other to enter the view in its area. Opening discovery works great. However, when I try to reference another region to introduce a view, I get an exception:

KeyNotFoundException
The region manager does not contain the MyRegion region.

When I look in the RegionManager areas, neither the one I'm trying to enter into the view exists, or the one that uses discovery detection.

Does it matter that I'm in another Shell window? I thought that there is only one RegionManager, but there must be two for my discovery of discoveries that will still work ...? Or is it because I have two new regions created later in the application life cycle? Or is it because new regions are not inside my MainRegion?

EDIT:
After some digging, it looks like the region is created, but it cannot find the RegionManager instance, so it is not added. Any clues?

+4
source share
1 answer

Sorted now. I needed to register a region manager in the constructor of my presenter class.
Thus, the regions in my new window can find my global manager of regions.

RegionManager.SetRegionManager(view as DependencyObject, regionManager);

+7
source

Source: https://habr.com/ru/post/1299744/


All Articles