Prism: Error declaring region inside a tab

Topics: Prism v4 - WPF 4
Jan 24, 2013 at 4:38 PM
Edited Jan 24, 2013 at 5:17 PM

Hi

 

I am having a strange problem; 

In my application I have a shell with a region "MainView", that holds a mainview; Inside the mainview, I have a 2 tabs, each of them has its own region (with different names). Both views that register to the regions using RegisterViewWithRegion are working and everything is ok. BTW regions are declared as contentControl.

Now my problem is that I want to add a region to the internal view that sits on the second tab.

When I add this to the XAML (Without register nothing in the code)

 <ContentControl rgn:RegionManager.RegionName="Test123" />

 - the application hangs for a minute in some loop in the region creation, and ends up with exception that hold many many exceptions inside - copy the exception text to notepad shows 70,000 lines.

Any idea why?

My guess is that the RegisterViewWithRegion is creating the parent window, and wants to create the region, but the tab is not selected so its not loaded yet, and this cause some mess with the region manager.

Link to the log file (~14 Mega)

 

Thanks for any help,

Ady.

 

Edit:

I moved the  <ContentControl rgn:RegionManager.RegionName="Test123" /> to the first tab, also happening. 

Developer
Jan 24, 2013 at 8:17 PM

Hi Ady,

So far we have not been able to find the exact cause behind this error, but according the stack trace the exceptions seem to be related to a problem when creating a "Measure.Options" region. According to the exception message, it seems that the ContentControl where this region is being attached has its Content property populated or bound to a source (for example, by using a Binding):

"An exception occurred while creating a region with name 'Measure.Options'. The exception was:
System.InvalidOperationException: ContentControl's Content property is not empty.
This control is being associated with a region, but the control is already bound to something else. If you did not explicitly set the control's Content property, this exception may be caused by a change in the value of the inherited RegionManager attached property."

In would be helpful if you could provide us with more information regarding this region, for example, where the region is declared, how it relates to other regions, etc. so that we can help you find the cause behind the exception.

Regards,

Damian Cherubini
http://blogs.southworks.net/dcherubini

Jan 24, 2013 at 9:21 PM
Edited Jan 24, 2013 at 9:22 PM

Thanks Damian

 

I don't understand why this exception raise when I add this <ContentControl rgn:RegionManager.RegionName="Test123" /> to a XAML that is not connected at all. Something went wrong with the region manager and I guess that adding  this to the XAML is not the real problem.

I will check it next week and update.

 

Thanks,

 

Ady.