RegionManager not found

Jan 28, 2010 at 1:47 PM

Given this XAML:

<UserControl x:Class="LLNet.Modules.Pages.Views.MainFrame"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:cal="http://www.codeplex.com/CompositeWPF"
>
    <StackPanel>
        <TabControl cal:RegionManager.RegionName="OuterRegion" ></TabControl>
        <Frame>
            <Frame.Content>
                <TabControl cal:RegionManager.RegionName="InnerRegion" ></TabControl>
             </Frame.Content>
        </Frame>
    </StackPanel>
</UserControl>

 

The "OuterRegion" gets registered but the "InnerRegion" does not.  This appears to be because when the RegionManagerRegistrationBehavior.TryRegisterRegion() is called in the second case the RegionManager is null. 

Can anyone tell me why (or, more to the point) how to get this to work.....

 

Jan 28, 2010 at 7:07 PM

I had a similar situation trying to declare submenu items in a RibbonDropDownButton control as regions.

For me this thread helped:

http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=59627

I've modified the RegionManagerRegistrationBehavior::FindRegionManager method in Microsoft.Practices.Composite.Presentation according to the above sited post:

... (line 161)

#else
            parent = LogicalTreeHelper.GetParent(dependencyObject);
            if (parent == null)
            {
                parent = System.Windows.Media.VisualTreeHelper.GetParent(dependencyObject);
            }
#endif
            if (parent != null)
            {
                return this.FindRegionManager(parent);
            }

Hope it works for you.

Regards,

Antonia

 

 

 

Jan 29, 2010 at 9:02 AM

Hi,

Thank you! Worked perfectly (although I not keen on having to modify the library :-{ )