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. Image for the cookie policy date
close icon

Remove TabItem (not hide) from TabControlExt

Hello,

I am using TabControlExt. Items of TabControl are binded to ObservableCollection. I have SelectedItem binded to TItem in ViewModel.

When user select some item in menu, new item is added to ObsevableCollection and new TabItem is shown.

That is working fine.

In the TabControlExt there is close (x) button. When I click that button, TabItem is removed from TabControl.

Problem is that TabItem is not removed from Collection, it is just hidden.

When user make new selection through menu, all TabItems get show.

example:

1. user open 5 items (TabItem1, TabItem2, TabItem3, TabItem4, TabItem5)
2. user close 2 items (TabItem1 and TabItem3)
3. user make new selection and want to open TabItem6

In that moment, 6 TabItems are shown: TabItem1, TabItem2, TabItem3, TabItem4, TabItem5 and TabItem6

How can I source TabControlExt close button to remove selected item (TItem) from ObservableCollection that is ItemsSource of TabControlExt.

Thank You.

5 Replies

VJ Victory Jessie Selvam D Syncfusion Team December 15, 2015 10:29 AM UTC

Hi Vladimir Culum,

Thank you for using Syncfusion products.

The value of CloseMode property in TabControlExt is Hide by default so it does not remove the tab item from collection when closed. We suggest you to set CloseMode.Delete for this property so that the closed tab item will be removed from the ItemCollection. We have prepared a sample and video to demonstrate the same and you can dowload it from the following link:

Knowlege Base link: https://www.syncfusion.com/kb/3605/how-to-update-the-tabitemcollection-when-any-one-of-its-tabitem-gets-closed

Sample: TabControl_Remove_Items

Video: Video

Regards,
Jessie


VC Vladimir Culum December 15, 2015 06:42 PM UTC

Jessie,

Thanks for quick reply.

I have different problem. I know CloseMode properties.

I have empty ObservableCollection TItems. When user click on menu item, new item is added in TItems and TabItem is shown.
When I click close button, Item is not removed from ObservableCollection, and next time I add new one, all items that were added is shown.

That is my problem.

Thanks.


VJ Victory Jessie Selvam D Syncfusion Team December 16, 2015 12:26 PM UTC

Hi Vladimir Culum,

We have prepared a sample with menu for creating and selecting TabItemExt but still we were unable to reproduce the reported issue with that. Could you please update us your Essential Studio version and modified sample reproducing the issue? You can download the sample from the following link:

Sample: TabControl_Remove_Items

Regards,
Jessie


VC Vladimir Culum May 4, 2016 10:13 PM UTC

Sorry. I just realise that I didn`t make update on this issue.

I resolve the problem.

Problem was in my code arch. I make update to ObservableCollection that was bind to TabExt ItemsSource from service, and didn`t make TwoWay update onClose in my ViewModel.

This is working as expected.

Thank You.


VR Vijayalakshmi Roopkumar Syncfusion Team May 5, 2016 05:42 AM UTC

Hi Vladimir,

We are glad to hear that the issue has been resolved at your end. Please get back with us if you need any further assistance.

Regards,
Vijayalakshmi V.R.

Loader.
Live Chat Icon For mobile
Up arrow icon