Prism Region Manager and ContentPresenter

Very brief note, so I don’t forget the circumstances: I may write a sample later. When you define Prism region in your view like this:

<igDock:TabGroupPane prism:RegionManager.RegionName="SomeRegion" />

Prism has two-staged process that brings your region to existance. First it needs to create a Region object, this is done by DelayedRegionCreationBehavior. Then it attaches your region to a region manager in RegionManagerRegistrationBehavior. The $1M question is: what region manager? To answer that, Prism walks up the logical tree to find a parent view with an already attached region manager (e.g. the shell).

The trouble is, if there is a ContentPresenter in the way, it won’t work. Experiment shows that ContentPresenter adds its child to the visual tree, but not to the logical tree. See also here. So, the region manager instance won’t be found, and the region object will be created, but not added to any region manager.

The program will continue without error until you actually try to access that region.

Leave a Reply

Your email address will not be published. Required fields are marked *