close button on tab

5 posts, 0 answers
  1. matias
    matias avatar
    4 posts
    Member since:
    Feb 2009

    Posted 12 Feb 2009 Link to this post

    hi, i am new on telerik wpf
    i am using tab control to show different usercontrols inside (as different views)

    i would like to have a close button on the tab like ie or firefox has
    is this possible?

    THANKS!
  2. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 16 Feb 2009 Link to this post

    Hi matias,

    There is no such built-in functionality, but it is quite easy to create.

    There is a similar thread here for the Silverlight TabControl, the suggestions there are valid for wpf as well:

    http://www.telerik.com/community/forums/silverlight/tabcontrol/how-to-close-the-tab.aspx

    Another thing you can do in WPF is use commands. Commands are attached to buttons and when the button is clicked, a routed event is raised on the button. You can handle the event anywhere on its route down to the application.  

    Commands are a very powerful concept, this MSDN article gives more details abou them:

    http://msdn.microsoft.com/en-us/magazine/cc785480.aspx

    To summarize: You need to handle the Click event of a button placed in the Header of a TabItem. Quite possibly the TabItems will be created dynamically and hence you will not have a direct access to the button, because it will be a part of a DataTemplate. Then you need use either a custom header (UserControl), routed events or routed commands to act on the button click.

    All the best,

    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jonathan
    Jonathan avatar
    134 posts
    Member since:
    Sep 2007

    Posted 18 May 2011 Link to this post

    Is there any chance you could put a demo project together for this in WPF? dnamically created tabs with a close button along with some regular staic tabs on the same radtabcontrol...
  5. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 24 May 2011 Link to this post

    Hello Jonathan,

    I prepared a sample for you that uses Style for the "Closeable" tabs and ViewModels. Unfortunately, there is no way to have both static RadTabItems and other that are bound to ViewModels. Instead you can have StyleSelector to select different Styles for the different TabItems.

    Greetings,
    Petar Mladenov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Jonathan
    Jonathan avatar
    134 posts
    Member since:
    Sep 2007

    Posted 04 Jun 2011 Link to this post

    Thanks!
Back to Top
UI for WPF is Visual Studio 2017 Ready