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>
4

1 回答 1

1

上述 XAML 违背了 PRISM 区域的设计。

所有区域都应该附加到从 ContentControl 派生的控件。加载区域注册视图的过程将区域容器的内容替换为为该区域名称注册的任何匹配视图。这将删除您的嵌套区域名称,因此您看到的错误是正确的。

这个想法是,为指定区域名称注册的视图本身可以包含其他区域。

于 2010-08-27T22:08:10.710 回答