Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8559923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:09:51+00:00 2026-06-11T16:09:51+00:00

I am workin on tab Controls in WPF. I have added a set of

  • 0

I am workin on tab Controls in WPF. I have added a set of tabs in my tab control and also implemented Close button method which works fine.

private void CloseTab(object source, RoutedEventArgs args)
    {            
        TabItem tabItem = args.Source as TabItem; 

        if (tabItem != null)
        {
            TabControl tabControl = tabItem.Parent as TabControl;
            if (tabControl != null)
                tabControl.Items.Remove(tabItem);             

        }            
    }

XAML:

<TabControl Name="ConnectTab" Style="{DynamicResource styleBackground}">
                        <tablocal:CloseableTabItem Header="Connect" > 
                        </tablocal:CloseableTabItem>
                        <tablocal:CloseableTabItem Header="I2C" />
                        <tablocal:CloseableTabItem Header="Voltage" />
                        <tablocal:CloseableTabItem Header="Clock" />

The problem i am facing is to keep one tab active(shouldnt close) after all the tabs have been closed. Basically the last tab left in tabcontrol shud not close even if user clicks the X button on tab.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:09:52+00:00Added an answer on June 11, 2026 at 4:09 pm

    Change the condition to –

    if (tabControl != null && tabControl.Items.Count > 1)
        tabControl.Items.Remove(tabItem); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with 3 tab controls on it, and each tab control
I have a WPF application with a screen containing a tab control with two
I'm trying to setup the tab keyboard control options on my current WPF project
I am currently working on a project which has a tab control which contains
I have a tabhost with 4 tabs. Each tab has several editboxes. On real
In a Win32 API C++ project, I have a dialog with a tab control
In Silver light Tab control ,i have adding custom tab header (name along with
I have a tab control with a data template that renders data based on
I have a tab control on a page; its items are bound back to
I have an app that uses ActionBarSherlock to provide a ViewPager control for tab

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.