)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to update the TabItemCollection when any one of its TabItem gets closed?

Platform: WPF |
Control: TabControlExt |
Published Date: January 29, 2015 |
Last Revised Date: January 29, 2015 |
.NET Framework: 4.5 |
Product Version: 12.3.0.36

To update the TabItemcollection when any one of its TabItemExt gets closed, set the CloseMode Property of TabControlExt to “Delete”.

CloseMode property:

The CloseMode is an enum that includes values as Hide and Delete that resides in the TabControlExt. When you click on the TabItemExt CloseButton and when the CloseMode is set to be Hidden, then the TabItemExt moves to the Hidden state. When the CloseMode is set to Delete, then the TabItemExt is removed from the TabControlExt, and it automatically gets deleted from the TabItems Collection.

You can achieve the above using the following code example.

XAML

The following is the Code Behind code example.

C#

 

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment
Comments
Craig Greenway
May 10, 2016
Please can you provide details on how to set the TabControlExt CloseMode default at either runtime or design time. I add new tabs at runtime based on user controls but can't find how to access the TabControlExt as I don't specify this myself. I add tabs like this (TableEditor is a User Control): var newTable = new TableEditor(_selectedTableName) { Name = "TableEditor" + _selectedTableName }; TablesDockingManager.BeginInit(); DockingManager.SetDockingManager(newTable, TablesDockingManager); DockingManager.SetHeader(newTable, "Table " + _selectedTableName); DockingManager.SetState(newTable, DockState.Document); DockingManager.SetDesiredMinWidthInDockedMode(newTable, 200); TablesDockingManager.Children.Add(newTable); TablesDockingManager.EndInit(); Reply
Vijayalakshmi Roopkumar [Syncfusion]
May 10, 2016
Hi Craig, Thank you for using Syncfusion Products, By default, TabItemExt in TabControlExt will not be removed from memory when we close the TabItem and its instances are maintained in memory. To clear the TabItemExt instance from memory, we need to set CloseMode as Delete. But it will not remove the child from Children collection of DockingManager. We can remove the child from Children collection of DockingManager by removing it from the children collection manually when the DockState is changed to Hidden. Please refer to the following code example. private void TableDockingManager_DockStateChanged(FrameworkElement sender, DockStateEventArgs e) { if(e.NewState == DockState.Hidden) { // Used to remove the children from the DockingManager TableDockingManager.Children.Remove(sender); } } Please find the sample from the following link: Sample link: http://www.syncfusion.com/downloads/support/forum/124023/ze/TabControlExt_124023-920575162 Regards, Vijayalakshmi V.R. Reply

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon