'宣言 Public Shared ReadOnly SelectNextTab As RoutedCommand
public static readonly RoutedCommand SelectNextTab
using Infragistics.Windows.Controls; private void ExecuteCommands() { // This command will select the first selectable tab, ignoring tabs // that are not visible or enabled this.xamTabControl1.ExecuteCommand(TabControlCommands.SelectFirstTab); // This command will select the next selectable tab, ignoring tabs // that are not visible or enabled this.xamTabControl1.ExecuteCommand(TabControlCommands.SelectNextTab); // This command will select the previous selectable tab, ignoring tabs // that are not visible or enabled this.xamTabControl1.ExecuteCommand(TabControlCommands.SelectPreviousTab); // This command will select the last selectable tab, ignoring tabs // that are not visible or enabled this.xamTabControl1.ExecuteCommand(TabControlCommands.SelectLastTab); // This command will close all tabs, i.e. set their Visibility property // to 'Collapsed'. To unclose the tabs set their Visibility back to // 'Visible' (see code in btnUncloseAllTabs_Click event handler below) this.xamTabControl1.ExecuteCommand(TabControlCommands.CloseAll); // This command will close the selcted tab if he XamTabControl's // 'AllowTabClosing' property is not set and is not overridden // via the TabItemEx's 'AllowClosing' property. this.xamTabControl1.ExecuteCommand(TabControlCommands.CloseSelected); // This command will expand a minimized XamTabControl. The command // is disabled if the 'IsMinimized' property is false. if ( this.xamTabControl1.IsMinimized == true) this.xamTabControl1.ExecuteCommand(TabControlCommands.Expand); // This command will minimize a XamTabControl. The command // is disabled if the 'IsMinimized' property is true or the // 'AlowMinimize' property is false. if ( this.xamTabControl1.IsMinimized == false && this.xamTabControl1.AllowMinimize == true) this.xamTabControl1.ExecuteCommand(TabControlCommands.Minimize); // This command will toggle the value of the 'IsMinimized' property. // The command is disabled if the 'AlowMinimize' property is false. if ( this.xamTabControl1.AllowMinimize == true) this.xamTabControl1.ExecuteCommand(TabControlCommands.ToggleMinimized); } private void btnUncloseAllTabs_Click(object sender, RoutedEventArgs e) { int count = this.xamTabControl1.Items.Count; ItemContainerGenerator generator = this.xamTabControl1.ItemContainerGenerator; // loop over all the tab items in the XamTabControl and set their // Visibility property to 'Visibile' to un-close them. for (int i = 0; i < count; i++) { TabItem tabItem = generator.ContainerFromIndex(i) as TabItem; if (tabItem != null) tabItem.Visibility = Visibility.Visible; } }
Imports Infragistics.Windows.Controls Private Sub ExecuteCommands() ' This command will select the first selectable tab, ignoring tabs ' that are not visible or enabled Me.XamTabControl1.ExecuteCommand(TabControlCommands.SelectFirstTab) ' This command will select the next selectable tab, ignoring tabs ' that are not visible or enabled Me.XamTabControl1.ExecuteCommand(TabControlCommands.SelectNextTab) ' This command will select the previous selectable tab, ignoring tabs ' that are not visible or enabled Me.XamTabControl1.ExecuteCommand(TabControlCommands.SelectPreviousTab) ' This command will select the last selectable tab, ignoring tabs ' that are not visible or enabled Me.XamTabControl1.ExecuteCommand(TabControlCommands.SelectLastTab) ' This command will close all tabs, i.e. set their Visibility property ' to 'Collapsed'. To unclose the tabs set their Visibility back to ' 'Visible' (see code in btnUncloseAllTabs_Click event handler below) Me.XamTabControl1.ExecuteCommand(TabControlCommands.CloseAll) ' This command will close the selcted tab if he XamTabControl's ' 'AllowTabClosing' property is not set and is not overridden ' via the TabItemEx's 'AllowClosing' property. Me.XamTabControl1.ExecuteCommand(TabControlCommands.CloseSelected) ' This command will expand a minimized XamTabControl. The command ' is disabled if the 'IsMinimized' property is false. If (Me.XamTabControl1.IsMinimized = True) Then Me.XamTabControl1.ExecuteCommand(TabControlCommands.Expand) End If ' This command will minimize a XamTabControl. The command ' is disabled if the 'IsMinimized' property is true or the ' 'AlowMinimize' property is false. If (Me.XamTabControl1.IsMinimized = False AndAlso Me.XamTabControl1.AllowMinimize = True) Then Me.XamTabControl1.ExecuteCommand(TabControlCommands.Minimize) End If ' This command will toggle the value of the 'IsMinimized' property. ' The command is disabled if the 'AlowMinimize' property is false. If (Me.XamTabControl1.AllowMinimize = True) Then Me.XamTabControl1.ExecuteCommand(TabControlCommands.ToggleMinimized) End If 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