2

I have a Menu (Telerik RadMenu) that has nested regions defined in the Shell. In my modules I will register the modules menu or toolbar items with these regions. Everything works fine for the root regions, but when I try and add something to a child region, such as the File region on the Menu, I get the error "The exception message was: The region manager does not contain the FileMenuRegion region."

However like I said if I change this code

regionManager.Regions[RegionNames.FileMenuRegion].Add(menuItem);

to this

regionManager.Regions[RegionNames.MainMenuRegion].Add(menuItem);

everything works fine. Below is the XAML for my menu so you can see the region names and how they are constructed. Any help would greatly be appreciated as this is bewildering and driving me crazy.

Menu

    <telerikNavigation:RadMenu x:Name="menuMain" DockPanel.Dock="Top" prismrgn:RegionManager.RegionName="{x:Static i:RegionNames.MainMenuRegion}" telerik:StyleManager.Theme="{Binding Source={StaticResource settings}, Path=Default.CurrentTheme}">
            <telerikNavigation:RadMenuItem Header="{x:Static p:Resources.File}" prismrgn:RegionManager.RegionName="{x:Static i:RegionNames.FileMenuRegion}">
                <telerikNavigation:RadMenuItem Header="{x:Static p:Resources.Exit}" Command="{Binding ExitCommand}">
                    <telerikNavigation:RadMenuItem.Icon>
                        <Image Source="../Resources/Close.png" Stretch="None" />
                    </telerikNavigation:RadMenuItem.Icon>
                </telerikNavigation:RadMenuItem>
            </telerikNavigation:RadMenuItem>
        </telerikNavigation:RadMenu>

1 Answers1

1

The above XAML goes against the design of PRISM regions.

All regions are supposed to to be attached to controls derived from ContentControl. The process of loading region registered views replaces the content of the region container with any matching views registered for that region name. That removes your nested region name so the error you see is correct.

The idea is, that a view registered for a specified region name can itself contain other regions.

iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202
  • so is there a way in having nested regions or not? Please take a look at [this](http://compositewpf.codeplex.com/discussions/249769#post725985) comment to understand my exact issue - note, it's the 3rd post in that thread. Thanks! – Shimmy Weitzhandler Jan 16 '12 at 21:09
  • 1
    Regions are layout building blocks only. The process of nesting implies that you actually want replaceable areas within replaceable areas. The solution would be to register views in the top level region as usual, that each contain other region definitions. User controls can have regions, often to simply insert status information provided by sources unknown. – iCollect.it Ltd Jan 17 '12 at 11:21
  • I found my answer. posted [here](http://compositewpf.codeplex.com/discussions/249769#post726075). – Shimmy Weitzhandler Jan 17 '12 at 13:49