MVVM Prism Nested Regions Can't Find Child Regions
- by Garry Clark
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>