Implementing 'close all' functionality

5 posts, 0 answers
  1. Greg
    Greg avatar
    3 posts
    Member since:
    Jul 2012

    Posted 23 Jul 2012 Link to this post

    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?
  2. Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 26 Jul 2012 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Greg
    Greg avatar
    3 posts
    Member since:
    Jul 2012

    Posted 01 Aug 2012 Link to this post

    Viktor --

    Can you provide an example of this?
  5. Greg
    Greg avatar
    3 posts
    Member since:
    Jul 2012

    Posted 01 Aug 2012 Link to this post

    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.
  6. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 06 Aug 2012 Link to this post

    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.

Back to Top
UI for WPF is Visual Studio 2017 Ready