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?
views:
41answers:
2
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
2009-05-19 00:12:05
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
2009-05-19 01:37:46
A:
public class CloseableItemsTabControl : TabControl
{
protected override DependencyObject GetContainerForItemOverride()
{
return new CloseableTabItem();
}
}
gschuager
2009-05-20 01:26:16