Nov 19, 2011 at 6:14 PM
Edited Nov 19, 2011 at 6:19 PM
newbie question. I am building a Pism app that has multiple modules where each module will load thier own menus. ModuleA has a number of views and each view has an associated menu that gets loaded in the MenuRegion when the module loads.
The current implementation that just loads the menus is working fine but the menu's are always enabled. I want to enable the menu when the view is activated and disable the menu when the view is deactivated. I define a view for each menu like the
following: The MenuRegion is defined as a Menu
Header="View One Menu">
<MenuItem Header="Item A" />
<MenuItem Header="Item B" />
I add the menu to the MainMenu region when the Module loads as follows:
Now I would like to enable or disable this menu when the associated view is enable/disabled. So in the ViewOneViewModel I thought I could do something like the following:
public void OnNavigatedFrom(NavigationContext navigationContext)
var regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
var region = regionManager.Regions["MainMenu"];
UserControl menu = (UserControl)region.GetView("ViewOneMenuView");
menu.IsEnabled = false;
This did not work since the menuItem being inserted into the MainMenu region is of type MenuItem which does not have a Name. and therfore region.getView() could not locate it.
How do I fix this?