Version

Close a Tab

If you add TabItemEx objects to xamTabControl™ and the xamTabControl’s AllowTabClosing property is set to True, an end user can close a tab by middle clicking the tab’s header.

Note
Note

When an end user closes a tab, xamTabControl does not remove the tab from the Items collection; it hides the tab. If a tab contains resource-heavy objects, you may want to remove the closed tab from the Items collection.

The following example code demonstrates how to close a tab.

In XAML:

<Button
    Content="Close the selected tab"
    Command="{x:Static igWindows:TabControlCommands.CloseSelected}"
    CommandTarget="{Binding ElementName=xamTabControl1}" />
<igWindows:XamTabControl Name="xamTabControl1" AllowTabClosing="True">
    <igWindows:TabItemEx Header="Tab 1">
        <!--TODO: Add content here-->
    </igWindows:TabItemEx>
    <igWindows:TabItemEx Header="Tab 2">
        <!--TODO: Add content here-->
    </igWindows:TabItemEx>
    <igWindows:TabItemEx Header="Tab 3">
        <!--TODO: Add content here-->
    </igWindows:TabItemEx>
</igWindows:XamTabControl>

In Visual Basic:

Imports Infragistics.Windows.Controls
...
Me.xamTabControl1.ExecuteCommand(TabControlCommands.CloseSelected)
...

In C#:

using Infragistics.Windows.Controls;
...
this.xamTabControl1.ExecuteCommand(TabControlCommands.CloseSelected)
...