Search code examples
wpftabcontroltabitem

How can I determine the type of the items that get added to a TabControl?


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?


Solution

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