tags:

views:

41

answers:

2

I've created a CloseableTabItem control that derives from TabItem. Now I'd like to specify that a given TabControl should add new items using CloseableTabItem instead of TabItem. Is this possible? How?

A: 

You'll probably need to make your own ClosableTabControl that extends TabControl in order to override the base functionality.

However, you can also probably just add your tabs manually, feeding it your ClosableTabItems instead of regular TabItems. It would be safe to assume this is possible since most collection-based controls are able to be programatically populated this way.

Soviut
About the first option... how can I extend TabControl to fulfil my requirement?About the second option... I don't own the code that populate the TabControl so I cannot do that. The things that are added to the TabControl are generally of UserControl type.
gschuager
A: 
public class CloseableItemsTabControl : TabControl
{
 protected override DependencyObject GetContainerForItemOverride()
 {
  return new CloseableTabItem();
 }
}
gschuager