Region / Dependency Property Issue

Jun 17, 2008 at 7:40 PM

Hi all,

I have two ItemsControls that are within a stackpanel. Each specifies a value for the RegionManager.RegionName dependency property. When I run my application in this way, everything works fine. The Prism framework ends up adding a ValueChanged delegate to the dependencypropertydescriptor and it executes some functionality for me.

However, when I change the nesting of my controls and put the 2nd ItemsControl into a stackpanel, like below:


    <ItemsControl prism:RegionManager.RegionName="{x:Static Regions:ShellRegionRegistry.GlobalCommandsRegion}" />


        <ItemsControl prism:RegionManager.RegionName="{x:Static Regions:ShellRegionRegistry.MainRegion}" />



Then, the delegate that was added to the ValueChanged event never fires, thus never creating the 'MainRegion' region. As a result, any module that attempt to reference the region ends up raising an exception.

Can anyone explain why placing my control, that references a dependency property, into a parent control seems to change the behavior of that dependency property being applied?


Matt Walters 
<!--[if !supportLineBreakNewLine]-->
Jun 17, 2008 at 8:23 PM
Hi Matt, thanks for the feedback.

The code you are using is a little old. We are not using the ValueChanged event anymore. Can you please check if this still happens with the latest drop?.


Ezequiel Jadib
Jun 18, 2008 at 2:14 AM
I am using the latest drop and am having similar issues.  I cannot get the OnSetRegionManagerCallback to see my regions even if I set the cal:RegionManager.RegionName attribute on the main grid.  At first I assumed it had to do with being unable to traverse the visual tree because the control I was using did not inherity from ContentControl, but then I tried the Grid, StackPanel, and Canvas all to no avail.  Any help would be greatly appreciated. 
Jun 19, 2008 at 2:35 PM
Hi Matt,

Julian is helping me on another thread with my issue and in that thread he states that panels are not supported because there is no included RegionAdapter for those.  You could override ConfigureRegionAdapterMappings in your custom BootStrapper and then create your own RegionAdapter to deal with this "I think".  What I did was this.

public override void ConfigureRegionAdapterMappings(){
    RegionAdapterMappings mappings = base.ConfigureRegionAdapterMappings();
    if(mappings != null){
       mappings.RegisterMapping(typeof(StackPanel), new StackPanelAdapter());

    return mappings;

then  you just need to implement a StackPanelAdapter, which should be pretty straight forward if you look at the ContentControlAdapter and the ItemsControlAdapter in the reference implementation.

Hope this helps,


Jun 19, 2008 at 5:40 PM
Hi Zul,

My problem was actually related to a bug in the RegionManager that has apparently been fixed, as Ezequiel suggested (Thanks, Ezequiel!). However, I'm having a similar issue understanding RegionAdapters. My scenario is that I'm trying to determine how to use a 3rd party docking panel solution with Prism / cWPF. If anyone has any samples for implementing RegionAdapters (especially for a docking solution such as DevComponent's or SyncFusion's :P ) I would love to see them.


Matt Walters
Jun 19, 2008 at 11:29 PM
Check the code in this thread to see if it helps you instead of creating an adapter for a panel:

       <ItemsControl cal:RegionManager.RegionName="YourRegionName">
                    <YourCustomPanel />
Jun 21, 2008 at 1:28 AM
Thanks for the lead.  I read through the post.  I was able to write my own adapter no problem prior to receiving this post so, I guess I have my problem solved for the moment.  Is there a reason you would recommend NOT writing your own RegionAdapters? 
Jun 21, 2008 at 8:20 PM
Hi, not really, I do recommend to write your own custom adapters for different controls. But in the case of panels, I think of them as mainly layout controls (to add look & feel), that can be an implementation detail (in most cases, but maybe not all) of an ItemsControl (which are lookless). In the cases were setting the ItemsControl.ItemsPanel property is enough, I would prefer to use that one instead of using a custom RegionAdapter, but that's just personal preference.