Version

ContextualTabItemCollection Class

An observable collection of RibbonTabItems.
Syntax
'Declaration
 
Public Class ContextualTabItemCollection 
   Inherits Infragistics.Collections.ObservableCollectionExtended(Of RibbonTabItem)
public class ContextualTabItemCollection : Infragistics.Collections.ObservableCollectionExtended<RibbonTabItem> 
Remarks

Note: The RibbonTabItems in this collection are not contained in the collection returned by the XamRibbon.Tabs property. They are, however, contained in the collection returned by the XamRibbon's read-only XamRibbon.TabsInView property.

Example
Xam_Ribbon_ContextualTabItemCollection Sample

<!-- Create a ContextualTabGroup.There are 6 different ContextualTabGroup Colors: Orange, Purple, Blue, Green, Yellow, and Red. -->
<igRibbon:ContextualTabGroup Key="SelectionGroup" Caption="Selection" IsVisible="True">
    
<igRibbon:ContextualTabGroup.Tabs>

        
<!-- Add a RibbonTabItem to this ContextualTabGroup.  Multiple TabItems can be added
        to the same ConxtextualTabGroup.  Each Tab will contain the same color as the ContextualTabGroup. 
-->
        
<igRibbon:RibbonTabItem Header="Font Selection">
            
<igRibbon:RibbonGroup Id="FontSelection" Caption="Font">
                
<igRibbon:ToolHorizontalWrapPanel>
                    
<igRibbon:ComboEditorTool
                      
Id="fontFamilyCombo_Selection"
                      
x:Name="fontFamilyCombo_Selection"
                      
DropDownResizeMode="VerticalOnly"
                      
IsEditable="False" Caption="Font Size"
                      
EditAreaWidth="148.0" Value="Arial">
                            
<igRibbon:ComboEditorTool.ItemsProvider>
                                
<igEditors:ComboBoxItemsProvider>
                                    
<Label Content="Arial"/>
                                    
<Label Content="Arial Black"/>
                                    
<Label Content="Calibri"/>
                                    
<Label Content="Times New Roman"/>
                                
</igEditors:ComboBoxItemsProvider>
                            
</igRibbon:ComboEditorTool.ItemsProvider>
                        
</igRibbon:ComboEditorTool>
                    
                    
<igRibbon:ComboEditorTool
                      
Id="fontSizeCombo_Selection"
                      
x:Name="fontSizeCombo_Selection"
                      
IsEditable="False"
                      
DropDownResizeMode="VerticalOnly"
                      
EditAreaWidth="118.0" Caption="Font Size"
                      
ValueType="{x:Type s:Double}" Value="10" >
                            
<igRibbon:ComboEditorTool.ItemsProvider>
                                
<igEditors:ComboBoxItemsProvider>
                                    
<Label Width="50" Content="8"/>
                                    
<Label Width="50" Content="9"/>
                                    
<Label Width="50" Content="10"/>
                                
</igEditors:ComboBoxItemsProvider>
                            
</igRibbon:ComboEditorTool.ItemsProvider>
                        
</igRibbon:ComboEditorTool>
                    
                    
<igRibbon:MenuTool
                        
igRibbon:RibbonGroup.MaximumSize="ImageOnly"
                        
SmallImage="Images\icons\Ribbon\FontColor.png" >
                        
<TextBlock Text="Colors"/>
                    
</igRibbon:MenuTool>
                
</igRibbon:ToolHorizontalWrapPanel>
            
</igRibbon:RibbonGroup>
        
</igRibbon:RibbonTabItem>

    
</igRibbon:ContextualTabGroup.Tabs>
</igRibbon:ContextualTabGroup>
Private xamRibbon As XamRibbon 
Private Sub addContextualTabGroups() 
'Code to create XamRibbon 

'add Ribbon Contextual Tab Groups 
    Dim contextualTG As New ContextualTabGroup() 
    contextualTG.Caption = "Sample CTG" 
    contextualTG.Key = "CG1" 
    contextualTG.BaseBackColor = Colors.Aqua 
    contextualTG.IsVisible = True 
    xamRibbon.ContextualTabGroups.Add(contextualTG) 
    
    
    'AddRange of ContextualTabGroups 
    Dim secondTG As New ContextualTabGroup() 
    secondTG.Caption = "Second CTG" 
    secondTG.Key = "CG2" 
    secondTG.IsVisible = True 
    
    
    Dim trirdTG As New ContextualTabGroup() 
    trirdTG.Caption = "Third CTG" 
    trirdTG.Key = "CG3" 
    trirdTG.IsVisible = True 
    
    
    Dim CTGList As New Infragistics.Windows.Helpers.ObservableCollectionExtended(Of ContextualTabGroup)() 
    
    CTGList.Add(secondTG) 
    CTGList.Add(trirdTG) 
    xamRibbon.ContextualTabGroups.AddRange(CTGList) 
    
    
    'add tabs to Contextual Tab Groups 
    Dim designTabItem As New RibbonTabItem() 
    designTabItem.Header = "Desin" 
    contextualTG.Tabs.Add(designTabItem) 
    'contextualTG.Key = "AB1"; 
    
    
    
    Dim layoutTabItem As New RibbonTabItem() 
    layoutTabItem.Header = "Layout" 
    contextualTG.Tabs.Add(layoutTabItem) 
    
    Dim secondTabItem As New RibbonTabItem() 
    secondTabItem.Header = "SecondCTab" 
    secondTG.Tabs.Add(secondTabItem) 
    'secondTG.Key = "AB2"; 
    
    addRibbonGroupsInContextualtabItems() 
    
End Sub 
Private Sub TabGroupProperties() 

    Dim resultString As String = "" 
    
    For Each igTabItem As RibbonTabItem In xamRibbon.Tabs 
        resultString += getTabItemParams(igTabItem) 
    Next 
    For Each ctgTabGroup As ContextualTabGroup In xamRibbon.ContextualTabGroups 
        For Each igTabItem As RibbonTabItem In ctgTabGroup.Tabs 
            resultString += getTabItemParams(igTabItem) 
        Next 
    Next 
    MessageBox.Show(resultString) 
End Sub 

Private Function getTabItemParams(ByVal igTabItem As RibbonTabItem) As String 
    Dim result As String = "" 
    If igTabItem.IsInContextualTabGroup Then 
        result += igTabItem.Header + " TabItem is in ContextualTabGroup" 
        result += " named " + igTabItem.ContextualTabGroup.Caption 
        If igTabItem.IsFirstTabInContextualTabGroup Then 
            result += " - FirstTabInContextualTabGroup" 
        End If 
        If igTabItem.IsLastTabInContextualTabGroup Then 
            result += " - LastTabInContextualTabGroup" 
        End If 
    Else 
        result += igTabItem.Header + " TabItem is not in ContextualTabGroup" 
    End If 
    result += " : Number of Groups-" + igTabItem.RibbonGroups.Count.ToString() 
    If igTabItem.IsMouseOverTab Then 
        result += " : mouse is over this RibbonTabItem" 
    End If 
    
    result += "" & Chr(10) & "" 
    Return result 
End Function
XamRibbon xamRibbon;
//Code to create XamRibbon

//add Ribbon Contextual Tab Groups
private void addContextualTabGroups()
{
	ContextualTabGroup contextualTG = new ContextualTabGroup();
	contextualTG.Caption = "Sample CTG";
	contextualTG.Key = "CG1";
	contextualTG.BaseBackColor = Colors.Aqua;
	contextualTG.IsVisible = true;
	xamRibbon.ContextualTabGroups.Add(contextualTG);


	//AddRange of ContextualTabGroups
	ContextualTabGroup secondTG = new ContextualTabGroup();
	secondTG.Caption = "Second CTG";
	secondTG.Key = "CG2";
	secondTG.IsVisible = true;


	ContextualTabGroup trirdTG = new ContextualTabGroup();
	trirdTG.Caption = "Third CTG";
	trirdTG.Key = "CG3";
	trirdTG.IsVisible = true;


	Infragistics.Windows.Helpers.ObservableCollectionExtended<ContextualTabGroup> CTGList =
		new Infragistics.Windows.Helpers.ObservableCollectionExtended<ContextualTabGroup>();

	CTGList.Add(secondTG);
	CTGList.Add(trirdTG);
	xamRibbon.ContextualTabGroups.AddRange(CTGList);


	//add tabs to Contextual Tab Groups
	RibbonTabItem designTabItem = new RibbonTabItem();
	designTabItem.Header = "Desin";
	contextualTG.Tabs.Add(designTabItem);
	//contextualTG.Key = "AB1";

	

	RibbonTabItem layoutTabItem = new RibbonTabItem();
	layoutTabItem.Header = "Layout";
	contextualTG.Tabs.Add(layoutTabItem);

	RibbonTabItem secondTabItem = new RibbonTabItem();
	secondTabItem.Header = "SecondCTab";
	secondTG.Tabs.Add(secondTabItem);
	//secondTG.Key = "AB2";

	addRibbonGroupsInContextualtabItems();

}	

void TabGroupProperties()
{
	string resultString = "";
	
	foreach (RibbonTabItem igTabItem in xamRibbon.Tabs)
	{
		resultString += getTabItemParams(igTabItem);
	}
	foreach (ContextualTabGroup ctgTabGroup in xamRibbon.ContextualTabGroups)
	{
		foreach (RibbonTabItem igTabItem in ctgTabGroup.Tabs)                {
			resultString += getTabItemParams(igTabItem);
		}
	}
	MessageBox.Show(resultString);
}

string getTabItemParams(RibbonTabItem igTabItem)
{
	string result = "";
	if (igTabItem.IsInContextualTabGroup)
	{
		result += igTabItem.Header + " TabItem is in ContextualTabGroup";
		result += " named " + igTabItem.ContextualTabGroup.Caption;
		if (igTabItem.IsFirstTabInContextualTabGroup)
		{
			result += " - FirstTabInContextualTabGroup";
		}
		if (igTabItem.IsLastTabInContextualTabGroup)
		{
			result += " - LastTabInContextualTabGroup";
		}
	}
	else
	{
		result += igTabItem.Header + " TabItem is not in ContextualTabGroup";
	}
	result += " : Number of Groups-" + igTabItem.RibbonGroups.Count.ToString();
	if (igTabItem.IsMouseOverTab)
	{
		result += " : mouse is over this RibbonTabItem";
	}

	result += "\n";
	return result;
}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also