CreateRegion executing twice

Topics: Prism v4 - Silverlight 4
Dec 11, 2010 at 12:27 AM


I have shell view with one region. In the shell view (not in the region mentioned) I have a docking control which gives my app a paned UI like visual studio. Some of the document panes added to the docking control contain regions and when multiple instances of the same pane are docked they must be scoped to avoid region name issues. I scope the regions like this:

var scopedRegionManager = shellRegionManager.CreateRegionManager();
RegionManager.SetRegionManager(paneView, scopedRegionManager);
I then add views to the regions in the scopedRegionManager.

I'm experiencing intermittent ArgumentExceptions which state that a region is already registered. After spending quite some time debugging, it looks like DelayRegionCreationBehavior.CreateRegion
is executing twice resulting in the creation of two instances of RegionManagerRegistrationBehavior for the same target element. So far I haven't been able to figure out why/how this is happening.

Any ideas?

Dec 13, 2010 at 2:45 PM


We´ve had no similar issues reported so far. It could be helpful if you could provide us with a repro sample or more information about your scenario, so we can help you solve this issue.


Miguel Bronzovic


Dec 13, 2010 at 3:11 PM

Thanks for replying Miguel.

The only issue that is similar is

I've spent two days trying to figure out what would cause DelayedRegionCreationBehavior.CreateRegion to be called twice. So far I don't understand how it's possible, but my debugging efforts seem to indicate that this is the cause of the problem. If you can think of a scenario where this could happen please let me know. So far I've made two changes: 1) Made WeakEventsManager thread safe 2) Changed DelayedRegionCreationBehavior.TryCreateRegion to the implementation below. I'm not confident these changes will fix the problem but I need to move on.




private void TryCreateRegion()
            DependencyObject targetElement = this.TargetElement;
            if (targetElement == null)

            if (targetElement.CheckAccess())            
{ if (!this.regionCreated) { this.Detach(); this.regionCreated = true; string regionName = this.RegionManagerAccessor.GetRegionName(targetElement); CreateRegion(targetElement, regionName); } } }



Dec 16, 2010 at 4:36 PM

Hi Joe,

Thank you for sharing your findings with the rest of the community, both here and in the Work Item you're pointing to.

Your workaround seems valid to mitigate the effects of this undesired behavior.

Thanks again.

Guido Leandro Maliandi