Version

ContainsKey Method

Determines whether OutlookBarGroupCollection contains an OutlookBarGroup with the specified key
Syntax
'Declaration
 
Public Function ContainsKey( _
   ByVal key As String _
) As Boolean
public bool ContainsKey( 
   string key
)

Parameters

key
The key if the OutlookBarGroup to check

Return Value

True if the OutlookBarGroup with the specified key exists, otherwise false
Example
Private  Sub Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim groups As OutlookBarGroupCollection =  New OutlookBarGroupCollection() 
 
    Dim gr As OutlookBarGroup
    gr = New OutlookBarGroup()
    gr.Header = "First"
    groups.Add(gr)
 
    gr = New OutlookBarGroup()
    gr.Header = "Second"
    groups.Add(gr)
 
    groups(0).Key = groups(0).Header.ToString() 
    groups(1).Key = groups(1).Header.ToString()
 
    If Not xamOutlookBar1.Groups.ContainsKey("First") Then
        xamOutlookBar1.Groups.InsertRange(0, groups)
        groups("First").IsSelected = True
    Else 
        xamOutlookBar1.Groups.RemoveRange(0, 2)
    End If
End Sub
private void Button_Click(object sender, RoutedEventArgs e)
{
    OutlookBarGroupCollection groups = new OutlookBarGroupCollection();

    OutlookBarGroup gr;
    gr = new OutlookBarGroup();
    gr.Header = "First";
    groups.Add(gr);

    gr = new OutlookBarGroup();
    gr.Header = "Second";
    groups.Add(gr);

    groups[0].Key = groups[0].Header.ToString(); 
    groups[1].Key = groups[1].Header.ToString();

    if (!xamOutlookBar1.Groups.ContainsKey("First"))
    {
        xamOutlookBar1.Groups.InsertRange(0, groups);
        groups["First"].IsSelected = true;
    }
    else
        xamOutlookBar1.Groups.RemoveRange(0, 2);
}
<Window x:Class="XamOutlookBarApp.IG_XamOutlookBar_Properties"
    
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    
xmlns:igOutlookBar="http://infragistics.com/OutlookBar"
    
Title="IG_XamOutlookBar_Properties" Height="300" Width="300">
    
<StackPanel Orientation="Horizontal">
        
<igOutlookBar:XamOutlookBar Name="xamOutlookBar1" Width="144">
            
<igOutlookBar:OutlookBarGroup Header="Group 1" Content="Group 1"/>
            
<igOutlookBar:OutlookBarGroup Header="Group 2" Content="Group 2"/>
        
</igOutlookBar:XamOutlookBar>
        
<StackPanel>
            
<Button Click="Button_Click">Add/Remove Groups</Button>
        
</StackPanel>
    
</StackPanel>
</Window>
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