private void UpdateTabs(bool clear) { if (Ribbon != null) { for (int i = 0; i < Ribbon.Items.Count; i++) { RibbonTab tab = Ribbon.ItemContainerGenerator.ContainerFromIndex(i) as RibbonTab; if (tab != null && tab.IsContextualTab && Object.Equals(tab.ContextualTabGroupHeader, Header)) { if (!clear) { tab.ContextualTabGroup = this; tab.CoerceValue(VisibilityProperty); } else { tab.CoerceValue(VisibilityProperty); tab.ContextualTabGroup = null; } } } } }
/// <summary> /// Property changed callback for ContextualTabGroupHeader property /// </summary> private static void OnContextualTabGroupHeaderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { RibbonTab ribbonTab = (RibbonTab)d; Ribbon ribbon = ribbonTab.Ribbon; if (ribbon != null) { ribbon.NotifyTabContextualTabGroupHeaderChanged(); if (e.NewValue != null && ribbonTab.Ribbon.ContextualTabGroupItemsControl != null) { ribbonTab.ContextualTabGroup = ribbonTab.Ribbon.ContextualTabGroupItemsControl.FindHeader(e.NewValue); } else { ribbonTab.ContextualTabGroup = null; } OnNotifyHeaderPropertyChanged(d, e); ribbonTab.CoerceValue(VisibilityProperty); } }