views:

286

answers:

1

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  A: 

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 pf 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.

Enough already