Regions Not Being Found

Jun 17, 2008 at 8:45 PM
I have  an app that mimics the StockTrader intialization process and my Regions are not being added to the RegionManager.Regions collection.  I have included the 



attribute to my control.  As well as one for the MainRegion and the MainToolBarRegion, added the constants to the Regions class in infrastructure, and also added 




to the xaml file.  OnSetRegionManagerCallback gets called but the none of the controls with the RegionName attribute set are getting passed to this method.  The controls in question do inherit from DependencyObject but are controls in the Actipro Suite of Navigation controls (third party).  Is there some hard coded registry of supported types that are monitored under the hood or something?  Do I need to somehow make the framework aware of the custom control library by registering these custom UI control types?  If so how do I do that? 


Jun 17, 2008 at 11:17 PM
Oh wait.  I think I see it.  RegionAdapterMappings.  I'll let you know if it works. 
Jun 18, 2008 at 2:34 AM
That in an off itself did not work.  So I did a little finegaling and it seems that while my controls with the cal:RegionManager.RegionName attribute are being passed to OnSetRegionManagerCallback the call to element.GetValue always returns null.  Anyone seen this?
Jun 18, 2008 at 3:54 PM
Make sure that the RegionManagerProperty has been set on the window.  This is done automatically if you return your window in the ShowShell method when using the UnityBootstrapper (see StockTraderRIBootstrapper.cs for an example of this).

If you are using your own bootstrapper or are trying to use the RegionManager directly, you should be able to call RegionManager.SetRegionManager(window, regionManager).

Jun 18, 2008 at 5:55 PM
Hi Brumfb,

I have BootStrapper that is almost identical to the StockTraderRIBoostrapper with the exception that I load my own modules in GetModuleEnumerator.  The UnityBootStrapper is setting the RegionManager on the Shell, but when the OnSetRegionManagerCallback fires this line

string regionName = element.GetValue(RegionNameProperty) as string

always evaluates to null which aborts the processing of the method. 

My issue is that I have cal:RegionManager.RegionName="appropriateValue" set on three controls but the call to element.GetValue never sees the RegionNameProperty.  So it seems to me that either A) my controls with the RegionNameProperty set are embedded in a containing control that is not passing its children to whataver low level code is traversing the tree or B) there is some other configuration I need to set that I have not or C) stuffs broke.  I have simplified my form dramatically to test scenario A by just having a grid in my Shell.xaml and setting the region name on the grid and then firing up the BootStrapper.  That did not solve my problem. 

So let me restate, I oversimplyfied my XAML by removing everything but a simple Grid and applied a cal:RegionManager.RegionName="MainRegion" attribute to that element and even that scenario resulted in 0 regions being Attached to the RegionManager because

string regionName = element.GetValue(RegionNameProperty) as string

always returns null.

Any ideas?
Jun 18, 2008 at 11:00 PM
I'm not sure what the problem is because I'm not able to repro it.
Anyways, Grids (or Panels) should not work with the attached property, because there are no region adapters that work with them out of the box. The controls that have region adapters are the ones that inherit from ContentControl or ItemsControl.
But the thing is that if you put a grid, you should get an exception, and not get a null region name on every control.
Can you provide more information on your scenario? what's the complete tree structure? Is there a way you could send me a sample app with this problem?

Julian Dominguez
Jun 19, 2008 at 12:12 AM
Sure I can send the whole solution.  Not sure you will be able to compile since I use the Actipro Control Library, but at least you can see what is going on.  Gimme a few and I will get it off to you.
Jun 19, 2008 at 6:53 PM
Edited Jun 19, 2008 at 6:58 PM

Hi, I've been looking at your code, and I stripped out the 3rd party controls, so the findings may not be entirely correct. One thing I found that may be causing this issue is that the Shell's constructor is not calling InitializeComponent(), so the region name property is not being set on the controls.

I also found that the names of the regions in the XAML do not correlate with the names in the code (you may want to use string constants to avoid this in the future)

Let me know if this helps,


Jun 19, 2008 at 9:46 PM
Thanks Julian,

Looks like the third party control vendor had a release where you could not call InitializeComponent in anything than inherited from RibbonWindow.  A subsequent service release fixed that and all is well.