RegionManager bug?

Topics: Prism v2 - WPF 3.5
Feb 9, 2009 at 4:19 PM

I have an application which works like Visual Studio; You have a tree view with items, and when you double click an item, a view for that item appears in a content region. (Like a code window in VS)
I've run into an issue regarding adding a view to a region.
What happens is that I get an exception saying that "The region manager does not contain the ContentRegion region".

The problem is that this only occurs after I have added one or more views to that region, and then removed all of them, so my "ContentRegion" does actually exist.
I was able to track the "problem" to Microsoft.Practices.Composite.Presentation.Regions.DefaultRegionManagerAccessor.GetRegionManager(...) which is called by Microsoft.Practices.Composite.Presentation.Regions.Behaviors.RegionManagerRegistrationBehavior.TryRegisterRegion().
GetRegionManager returns null for the content host, but it should have returned a region manager...
I don't understand why this only happens after I have removed (closed) all my views from a region.

After some investigation I discovered that if I set a value for x:Name on the content host, everything workes fine...GetRegionManager suddenly returns a region manager.
I do not understand this behavior. Can anyone shed some light on this?

Note: I'm using Infragistics, and the content hosts are TabGroupPanes contained in a xamDockManager.
I've got a region adapter for the TabGroupPane which seems to work just fine.



Feb 9, 2009 at 5:01 PM
This may be a bug, but regarding the "x:Name" workaround it may also be a behavior on the TabGroupPane... maybe it is recycling and recreating the tab group pane that is used to host the region, ignoring the fact that it was being "adapted".

Can you check if replacing the TabGroupPane with a host control that works natively with Prism still experiences this problem (for example a TabControl)?

Or if you have a small repro solution that we can use, that will also be helpful.

Julian Dominguez
Feb 9, 2009 at 9:08 PM

Hi Julian,

You are right, I only get this behavior with the TabGroupPane...the native controls works fine, so I guess I'll have to ask Infragistics about this one.

The workaround is easy so it's no big deal, I just thought it was a strange behavior.