Question

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?

Was it helpful?

Solution

public class CloseableItemsTabControl : TabControl
{
    protected override DependencyObject GetContainerForItemOverride()
    {
        return new CloseableTabItem();
    }
}

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top