예제 #1
0
 private async void TabStrip_TabCloseRequested(Microsoft.UI.Xaml.Controls.TabView sender, Microsoft.UI.Xaml.Controls.TabViewTabCloseRequestedEventArgs args)
 {
     if (TabStrip.TabItems.Count == 1)
     {
         await InstanceTabsView.StartTerminateAsync();
     }
     else if (TabStrip.TabItems.Count > 1)
     {
         int tabIndexToClose = TabStrip.TabItems.IndexOf(args.Tab);
         TabStrip.TabItems.RemoveAt(tabIndexToClose);
     }
 }
예제 #2
0
        private async void CloseSelectedTabKeyboardAccelerator_Invoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args)
        {
            var InvokedTabView = (args.Element as TabView);

            // Only close the selected tab if it is closeable
            if (((TabViewItem)InvokedTabView.SelectedItem).IsClosable)
            {
                if (TabStrip.TabItems.Count == 1)
                {
                    await InstanceTabsView.StartTerminateAsync();
                }
                else
                {
                    InvokedTabView.TabItems.Remove(InvokedTabView.SelectedItem);
                }
            }
            args.Handled = true;
        }