Cannot find Region in RegionManager (using PRISM)
I'm writing an application in Prism. I have a user control and contains two <ContentControl>
controls. These both have Regions assigned to them. The usercontrol is being hosted in a Window
that is being shown using ShowDialog()
.
KeyNotFoundException
The region manager does not contain the MyRegion region.When I look in the RegionManagers regions neither the one that I'm trying to inject the view exists or the one being that's using view discovery.
Does it matter that I'm in a different window to the Shell? I thought there was only one RegionManager, but there must be two for my view discovery to still be working...? Or is it because I have two new regions being created later in the applications life cycle? Or is it because the new regions aren't inside the my MainRegion?
EDIT:
After doing some digging it looks like the Region is created but it can't find an instance of the RegionManager so it doesn't get added. Any clues?Sorted now. I needed to register the region manager in the constructor of my presenter class.
That way the regions in my new window could find my global region manager.
RegionManager.SetRegionManager(view as DependencyObject, regionManager);
精彩评论