コード例 #1
0
        private int GetTabIndex(RibbonTabItem tabItem)
        {
            int index = Tabs.IndexOf(tabItem);
            if (index >= 0) return index;

            if (ContextualTabSet != null)
            {
                index = ContextualTabSet.Tabs.IndexOf(tabItem);
                return index + Tabs.Count;
            }
            return -1;
        }
コード例 #2
0
 private void SetSelectedTabItem(RibbonTabItem item)
 {
     SelectedGroups = item != null ? item.Items : null;
     ItemsSource = SelectedGroups;
     int index = SelectedTabIndex;
     for (int i = 0; i < Tabs.Count; i++)
     {
         item = Tabs[i];
         item.IsSelected = i == index;
     }
     RibbonContextualTabSet currentSet = ContextualTabSet;
     if (currentSet != null)
     {
         index -= Tabs.Count;
         currentSet.SetSelectedTabItem(index);
     }
     if (contextualTabSets != null)
     {
         foreach (var set in contextualTabSets)
         {
             if (set != currentSet)
             {
                 set.SetSelectedTabItem(-1);
             }
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// Selects the specified Tabitem.
 /// </summary>
 private void Select(RibbonTabItem tabItem)
 {
     int index = GetTabIndex(tabItem);
     bool isCurrent = index == this.SelectedTabIndex;
     this.SelectedTabIndex = index;
     if (CanMinimize)
     {
         if (isCurrent && IsExpanded) this.IsExpanded ^= true; else this.IsExpanded = true;
     }
 }
コード例 #4
0
 /// <summary>
 /// Gets the index for VisibleTabs of the specified tab, otherwise -1.
 /// </summary>
 /// <param name="item">The TabItem for which to determine the index.</param>
 /// <returns>The index related to <see cref="T:RibbonBar.VisibleTable"/>, otherwise -1.</returns>
 public int IndexOfVisibleTab(RibbonTabItem item)
 {
     if (item == null) return -1;
     int index = 0;
     foreach (var tab in VisibleTabs)
     {
         if (tab == item) return index;
         index++;
     }
     return -1;
 }