private void InitializeCommand(string header, Func <bool> isVisibleHandler, Func <bool> isEnabledHandler, Func <bool> isCheckedHandler, Action commandHandler) { string LocalizedText = Properties.Resources.ResourceManager.GetString(header, CultureInfo.CurrentCulture) !; ICommand Command = new RoutedUICommand(LocalizedText, header, GetType()); CommandList.Add(Command); MenuHeaderTable.Add(Command, LocalizedText); MenuIsVisibleTable.Add(Command, isVisibleHandler); MenuIsEnabledTable.Add(Command, isEnabledHandler); MenuIsCheckedTable.Add(Command, isCheckedHandler); MenuHandlerTable.Add(Command, commandHandler); }
/// <summary> /// Reads the state of a menu item associated to command. /// </summary> /// <param name="command">The command associated to the menu item.</param> /// <returns>True if the menu item is checked, false otherwise.</returns> public bool GetMenuIsChecked(ICommand command) { return(MenuIsCheckedTable[command]()); }