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

close button on tab

4 Answers 246 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
matias
Top achievements
Rank 1
matias asked on 12 Feb 2009, 06:14 PM
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!

4 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 16 Feb 2009, 11:31 AM

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.
0
Jonathan
Top achievements
Rank 1
answered on 19 May 2011, 03:24 AM
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...
0
Petar Mladenov
Telerik team
answered on 24 May 2011, 12:24 PM
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
0
Jonathan
Top achievements
Rank 1
answered on 04 Jun 2011, 05:26 AM
Thanks!
Tags
TabControl
Asked by
matias
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Jonathan
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or