Imports Infragistics.Windows.Controls
Imports Infragistics.Windows.Controls.Events
Imports System.Windows.Controls.Primitives
Imports System.Diagnostics
Imports System.Windows
Class Window1
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
' Allow tab closing by default.
Me.XamTabControl1.AllowTabClosing = True
' Note: tab closing can be overriden on each TabItemEx by setting its AllowClosing
' property, e.g.
TryCast(Me.XamTabControl1.Items(0), TabItemEx).AllowClosing = False
' Show a close button in the tab header area that will close the selected tab
Me.XamTabControl1.ShowTabHeaderCloseButton = True
' Show a close button in the TabItemEx if the tab is selected
' or if the mouse is over it.
Me.XamTabControl1.TabItemCloseButtonVisibility = TabItemCloseButtonVisibility.WhenSelectedOrHotTracked
' Note: tab item close button visibility can be overriden on each TabItemEx by
' setting its CloseButtonVisibility property, e.g.
TryCast(Me.XamTabControl1.Items(2), TabItemEx).CloseButtonVisibility = TabItemCloseButtonVisibility.Hidden
Dim tab As TabItemEx = TryCast(Me.XamTabControl1.Items(1), TabItemEx)
' Wire the Closing event for a specific tab. Setting Cancel to true inside the event will
' prevent the tab from being closed
AddHandler tab.Closing, AddressOf tabItem_Closing
' Note: when the XamTabControl closes a tab it leaves it in the Items
' collection and just sets the tab item's Visibility to 'Collapsed'.
' Therefore, to unclose a tab set its Visibility property back to 'Visible'
' (see the btnUncloseAllTabs_Click event handler below).
End Sub
Private Sub tabItem_Closing(ByVal sender As Object, ByVal e As TabClosingEventArgs)
' Setting Cancel to true will prevent the tab from being closed
e.Cancel = True
End Sub
Private Sub btnUncloseAllTabs_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
Dim count As Int32 = Me.XamTabControl1.Items.Count
Dim generator As ItemContainerGenerator = Me.XamTabControl1.ItemContainerGenerator
Dim tabItem As TabItem
' loop over all the tab items in the XamTabControl and set their
' Visibility property to 'Visibile' to un-close them.
For i As Int32 = 0 To count - 1
tabItem = TryCast(generator.ContainerFromIndex(i), TabItem)
If Not tabItem Is Nothing Then
tabItem.Visibility = Visibility.Visible
End If
Next
End Sub