This is a migrated thread and some comments may be shown as answers.

Implementing 'close all' functionality

4 Answers 170 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 23 Jul 2012, 03:49 PM
Is there are built-in way to have a 'close all' option appear in the RadTabControl's drop-down menu? We have a close button on each tab, but it would be nice to also have an option in the drop down to close everything out.

Can this also be easily done in a context menu?

4 Answers, 1 is accepted

Sort by
0
Viktor Tsvetkov
Telerik team
answered on 26 Jul 2012, 08:55 AM
Hello Greg,

There is no such built-in functionality, actually the close buttons on the tabs are not built-in and are application specific logic, so you should do this on your own (i.e. modify the ControlTemplate of the RadTabControl and add your specific logic).

Regards,
Viktor Tsvetkov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Greg
Top achievements
Rank 1
answered on 01 Aug 2012, 02:13 PM
Viktor --

Can you provide an example of this?
0
Greg
Top achievements
Rank 1
answered on 01 Aug 2012, 02:30 PM
I should also clarify that we've had little success in this. We use an ItemsSource for most all of our RadTabControl instances, and adding in a DropDownMenuItem to the ControlTemplate causes exceptions at runtime. I would rather not completely refactor code to manually add items to every single RadTabControl we use, so what is a better option?

I've thought about adding an item to our RadTabControl that's hidden somehow, making it's title "Close All Tabs", but this is a straight-up hack. I'd rather use something a bit more elegant.
0
Alex Fidanov
Telerik team
answered on 06 Aug 2012, 04:37 PM
Hello,

 To achieve this, I would suggest subclassing the RadTabControl and extending its logic. For example, you can create a DelegateCommand (or any other command) as a property of the customized tab control. Then you can edit the default control template and place a button and bind it to this custom close command. As the command is inside the tab control itself, you would have access to the container generator of the control, so that you can handle both Items and ItemsSource scenarios to get the containers and remove or hide them. This approach will also make the control reusable.

Please let us know if you need further assistance.

Regards,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
TabControl
Asked by
Greg
Top achievements
Rank 1
Answers by
Viktor Tsvetkov
Telerik team
Greg
Top achievements
Rank 1
Alex Fidanov
Telerik team
Share this question
or