private void ContextMenu_Loaded(object sender, RoutedEventArgs e) { var contextMenu = (sender as ContextMenu); var commandsMenu = contextMenu?.Items[0] as MenuItem; var conditionsMenu = contextMenu?.Items[1] as MenuItem; var treeViewItem = TreeViewCommands.ItemContainerGenerator.ContainerFromItem(contextMenu?.PlacementTarget) as TreeViewItem ?? contextMenu?.PlacementTarget as TreeViewItem; treeViewItem.IsSelected = true; if (contextMenu?.DataContext is RootBatchNode) { ((MenuItem)contextMenu?.Items[3]).IsEnabled = false; } else { ((MenuItem)contextMenu?.Items[3]).IsEnabled = true; } PluginToMenu.InitializeCommands(commandsMenu?.Items, false); PluginToMenu.InitializeConditions(conditionsMenu, false); }
private void Shortcut_Button_Loaded(object sender, RoutedEventArgs e) { PluginToMenu.InitializeCommands(((sender as Button)?.ContextMenu?.Items[0] as MenuItem)?.Items, false); }