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 169985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:43:40+00:00 2026-05-11T12:43:40+00:00

I’ve a WPF app organized with tabs. I added a small button to each

  • 0

I’ve a WPF app organized with tabs. I added a small button to each tabitem header that allow the user to close the tab.

When the user click on the small button, I remove the tabItem from the tabControl.

tabControl.Items.Remove(tabItem);

As result of this the tabItem dissapears, and that is fine, but here comes the problem:

The TabItem is not visible(good), but it still exists(bad). If I put a timer inside, the timer execucutes his Tick, and more important, if I’ve a datagrid with 200.000 records and I close the Tab, The garbage collector don’t release the memory as I expected.

I asked google about the problem and I’ve implemented some of the advices described. It didn’t work.

Can anyone help me? Thanks

  • 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. 2026-05-11T12:43:41+00:00Added an answer on May 11, 2026 at 12:43 pm

    This is what I’ve been using, and as far as I can tell it removes the tabitem from memory. The problem with leaving a timer inside of the tabitem, is that the GC won’t collect and dispose of it because it detects that the timer is still in use.

    The Code:

    namespace Reports.Controls {     /// <summary>     /// Interaction logic for Test.xaml     /// </summary>     public partial class ReportTab : TabItem     {         public delegate void CloseEvents(ReportTab TabIndex);         public event CloseEvents Closing;          public ReportTab(string Title)         {             InitializeComponent();             tbTitle.Text = Title;         }          private void Image_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)         {             Closing(this);         }     } } 

    The xaml:

    <TabItem x:Class='Reports.Controls.ReportTab'     xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'     xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'     >     <TabItem.Header>         <StackPanel Orientation='Horizontal'>             <TextBlock Text='Main' Name='tbTitle' Margin='0,0,8,0'/>             <Image Height='13'                     Source='pack://application:,,/Images/Icons/close.png'                    MouseLeftButtonUp='Image_MouseLeftButtonUp'/>         </StackPanel>     </TabItem.Header>     <Grid>          //Tabitem stuff     </Grid> </TabItem> 

    Here’s the page with the Tabcontrol to add a tab:

    void AddTab(string Title) {     Controls.ReportTab rt = new Controls.ReportTab(Title);     rt.Closing += new Controls.ReportTab.CloseEvents(rt_Closing);     tabControl.SelectedIndex = tabControl.Items.Add(rt); }  /// <summary> /// Moves the Tab Control back to the Main tab /// after a tab is removed /// </summary> /// <param name='TabIndex'></param> void rt_Closing(Controls.ReportTab TabIndex) {     tabControl.Items.Remove(TabIndex);     //This resets the tabcontrol back to it's first tabindex     tabControl.SelectedIndex = 0;  } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 229k
  • Answers 229k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer To express to client code what the intention of your… May 13, 2026 at 1:44 am
  • Editorial Team
    Editorial Team added an answer There are many third-party solutions available for automated deployment. You… May 13, 2026 at 1:44 am
  • Editorial Team
    Editorial Team added an answer I've only done minimal work with NUnit and Resharper, but… May 13, 2026 at 1:44 am

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS
I want use html5's new tag to play a wav file (currently only supported

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.