/// <summary> /// Occurs when the <see cref="RoutedCommand"/> needs to determine whether it can execute. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">A <see cref="CanExecuteRoutedEventArgs"/> that contains the event data.</param> private void toggleContextualTabGroupCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = true; e.Handled = true; ICheckableCommandParameter parameter = e.Parameter as ICheckableCommandParameter; if (parameter != null) { RibbonControls.ContextualTabGroup contextualTabGroup = ribbon.ContextualTabGroups[Convert.ToString(parameter.Tag)]; parameter.Handled = true; parameter.IsChecked = contextualTabGroup.IsVisible; } }
/// <summary> /// Occurs when the <see cref="RoutedCommand"/> is executed. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">An <see cref="ExecutedRoutedEventArgs"/> that contains the event data.</param> private void toggleContextualTabGroupCommand_Execute(object sender, ExecutedRoutedEventArgs e) { RibbonControls.ContextualTabGroup contextualTabGroup = null; ICheckableCommandParameter parameter = e.Parameter as ICheckableCommandParameter; if (parameter != null) { contextualTabGroup = ribbon.ContextualTabGroups[Convert.ToString(parameter.Tag)]; } else if (e.Parameter is string) { contextualTabGroup = ribbon.ContextualTabGroups[Convert.ToString(e.Parameter)]; } if (contextualTabGroup != null) { contextualTabGroup.IsActive = !contextualTabGroup.IsActive; // If making active, select the first tab in it // if ((contextualTabGroup.IsActive) && (contextualTabGroup.Items.Count > 0)) // ribbon.SelectedTab = (RibbonControls.Tab)contextualTabGroup.Items[0]; } }