HypernovaDesktop Components · docs
Binarymission
WPF › Tab Control › TabControl

TabControl

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WPF.Controls.Containers

A custom TabControl class that provides extended set of features.

public class TabControl : System.Windows.Controls.TabControl

Inherits from / implements: System.Windows.Controls.TabControl

Remarks

How this control works. Everything visible is in the default style ( Themes\Generic.xaml ). TabStripPlacement picks one of four control templates (top, bottom, left, right), and inside each a trigger on RenderingMode picks the tab items' template, which the item style takes from TabItemControlTemplate. Custom leaves that property to the application: a template set on it locally outranks the trigger. Colours. Every brush property takes its default from a key in TabControlResources through a dynamic resource, so an application or a skin in force redefines the key and every tab control follows; a brush set on the control itself wins over both. The control never adds or removes tabs itself. The add button raises AddNewTabItemClick; a tab's close button, a middle click on its header and Ctrl+F4 on the selected tab raise CloseTabItemClick. The application handles those and changes the items.

Members at a glance

AddNewItemButtonBackgroundGets or sets the add new item button background.
AddNewItemContentBrushGets or sets the add new item content brush.
AddNewTabItemTooltipTextGets or sets the add new tab item tooltip text.
ButtonLeftArrowGeometryPathFillBrushGets or sets the button left arrow geometry path fill brush.
ButtonLeftArrowGeometryPathStrokeBrushGets or sets the button left arrow geometry path stroke brush.
ButtonRightArrowGeometryPathFillBrushGets or sets the button right arrow geometry path fill brush.
ButtonRightArrowGeometryPathStrokeBrushGets or sets the button right arrow geometry path stroke brush.
CloseButtonCrossMarkColorBrushGets or sets the close button cross mark color brush.
CloseButtonStrokeBrushGets or sets the close button stroke brush.
CloseTabTooltipTextGets or sets the close tab tooltip text.
IsAddNewTabItemButtonVisibleGets or sets a value indicating whether the tab strip shows an add-new-tab button after its scroll buttons.
RenderingModeGets or sets the rendering mode.
ScrollButtonBrushGets or sets the scroll button brush.
ScrollButtonOnMouseOverBrushGets or sets the scroll button on mouse over brush.
TabControlBackgroundGets or sets the tab control background.
TabItemAccentBrushGets or sets the accent brush the modern rendering modes draw the selected tab's highlight with: the pill fill, the underline, the selection bar of side-placed tabs.
TabItemAccentForegroundGets or sets the brush for the text of a tab drawn on TabItemAccentBrush, such as the selected tab in Pill mode.
TabItemBorderBrushGets or sets the tab item border brush.
TabItemBorderOnMouseOverBrushGets or sets the tab item border on mouse over brush.
TabItemCloseButtonFillOnMouseOverBrushGets or sets the tab item close button fill on mouse over brush.
TabItemControlTemplateGets or sets the tab item control template.
TabItemFillOnMouseOverBrushGets or sets the tab item fill on mouse over brush.
TabItemPathBrushGets or sets the tab item path brush.
TabItemSelectedFillGets or sets the tab item selected fill.
TabItemTextForegroundGets or sets the tab item text foreground.
TabStripBackgroundGets or sets the brush painted behind the tab headers, including the scroll and add buttons. Null, the default, leaves the strip transparent so the parent shows through; set it when the parent is dark, because unselected tabs in the flat modes draw no fill of their own.
OnKeyDownCtrl+F4 asks for the selected tab to be closed, as it closes a document in Windows applications.
AddNewTabItemClickOccurs when the add-new-tab button at the end of the tab strip is clicked.
AddNewItemButtonBackgroundPropertyThe add new item button background property
AddNewItemContentBrushPropertyThe add new item content brush property
AddNewTabItemClickEventIdentifies the AddNewTabItemClick routed event.
AddNewTabItemTooltipTextPropertyThe add new tab item tooltip text property
ButtonLeftArrowGeometryPathFillBrushPropertyThe button left arrow geometry path fill brush property
ButtonLeftArrowGeometryPathStrokeBrushPropertyThe button left arrow geometry path stroke brush property
ButtonRightArrowGeometryPathFillBrushPropertyThe button right arrow geometry path fill brush property
ButtonRightArrowGeometryPathStrokeBrushPropertyThe button right arrow geometry path stroke brush property
CloseButtonCrossMarkColorBrushPropertyThe close button cross mark color brush property
CloseButtonStrokeBrushPropertyThe close button stroke brush property
CloseTabTooltipTextPropertyThe close tab tooltip text property
IsAddNewTabItemButtonVisiblePropertyIdentifies the IsAddNewTabItemButtonVisible dependency property.
RenderingModePropertyThe rendering mode property
ScrollButtonBrushPropertyThe scroll button brush property
ScrollButtonOnMouseOverBrushPropertyThe scroll button on mouse over brush property
TabControlBackgroundPropertyThe tab control background property
TabItemAccentBrushPropertyIdentifies the TabItemAccentBrush dependency property.
TabItemAccentForegroundPropertyIdentifies the TabItemAccentForeground dependency property.
TabItemBorderBrushPropertyThe tab item border brush property
TabItemBorderOnMouseOverBrushPropertyThe tab item border on mouse over brush property
TabItemCloseButtonFillOnMouseOverBrushPropertyThe tab item close button fill on mouse over brush property
TabItemControlTemplatePropertyThe tab item control template property
TabItemFillOnMouseOverBrushPropertyThe tab item fill on mouse over brush property
TabItemPathBrushPropertyThe tab item path brush property
TabItemSelectedFillPropertyThe tab item selected fill property
TabItemTextForegroundPropertyThe tab item text foreground property
TabStripBackgroundPropertyIdentifies the TabStripBackground dependency property.

Properties

AddNewItemButtonBackground

public Brush AddNewItemButtonBackground

Gets or sets the add new item button background.

Value. The add new item button background.

AddNewItemContentBrush

public Brush AddNewItemContentBrush

Gets or sets the add new item content brush.

Value. The add new item content brush.

AddNewTabItemTooltipText

public string AddNewTabItemTooltipText

Gets or sets the add new tab item tooltip text.

Value. The add new tab item tooltip text.

ButtonLeftArrowGeometryPathFillBrush

public Brush ButtonLeftArrowGeometryPathFillBrush

Gets or sets the button left arrow geometry path fill brush.

Value. The button left arrow geometry path fill brush.

ButtonLeftArrowGeometryPathStrokeBrush

public Brush ButtonLeftArrowGeometryPathStrokeBrush

Gets or sets the button left arrow geometry path stroke brush.

Value. The button left arrow geometry path stroke brush.

ButtonRightArrowGeometryPathFillBrush

public Brush ButtonRightArrowGeometryPathFillBrush

Gets or sets the button right arrow geometry path fill brush.

Value. The button right arrow geometry path fill brush.

ButtonRightArrowGeometryPathStrokeBrush

public Brush ButtonRightArrowGeometryPathStrokeBrush

Gets or sets the button right arrow geometry path stroke brush.

Value. The button right arrow geometry path stroke brush.

CloseButtonCrossMarkColorBrush

public Brush CloseButtonCrossMarkColorBrush

Gets or sets the close button cross mark color brush.

Value. The close button cross mark color brush.

CloseButtonStrokeBrush

public Brush CloseButtonStrokeBrush

Gets or sets the close button stroke brush.

Value. The close button stroke brush.

CloseTabTooltipText

public string CloseTabTooltipText

Gets or sets the close tab tooltip text.

Value. The close tab tooltip text.

IsAddNewTabItemButtonVisible

public bool IsAddNewTabItemButtonVisible

Gets or sets a value indicating whether the tab strip shows an add-new-tab button after its scroll buttons.

Value. true to show the button; the default is false .

The button is drawn with AddNewItemButtonBackground and AddNewItemContentBrush, shows AddNewTabItemTooltipText, and raises AddNewTabItemClick.

RenderingMode

public TabControlRenderingMode RenderingMode

Gets or sets the rendering mode.

Value. The rendering mode.

ScrollButtonBrush

public Brush ScrollButtonBrush

Gets or sets the scroll button brush.

Value. The scroll button brush.

ScrollButtonOnMouseOverBrush

public Brush ScrollButtonOnMouseOverBrush

Gets or sets the scroll button on mouse over brush.

Value. The scroll button on mouse over brush.

TabControlBackground

public Brush TabControlBackground

Gets or sets the tab control background.

Value. The tab control background.

TabItemAccentBrush

public Brush TabItemAccentBrush

Gets or sets the accent brush the modern rendering modes draw the selected tab's highlight with: the pill fill, the underline, the selection bar of side-placed tabs.

TabItemAccentForeground

public Brush TabItemAccentForeground

Gets or sets the brush for the text of a tab drawn on TabItemAccentBrush, such as the selected tab in Pill mode.

TabItemBorderBrush

public Brush TabItemBorderBrush

Gets or sets the tab item border brush.

Value. The tab item border brush.

TabItemBorderOnMouseOverBrush

public Brush TabItemBorderOnMouseOverBrush

Gets or sets the tab item border on mouse over brush.

Value. The tab item border on mouse over brush.

TabItemCloseButtonFillOnMouseOverBrush

public Brush TabItemCloseButtonFillOnMouseOverBrush

Gets or sets the tab item close button fill on mouse over brush.

Value. The tab item close button fill on mouse over brush.

TabItemControlTemplate

public ControlTemplate TabItemControlTemplate

Gets or sets the tab item control template.

Value. The tab item control template.

TabItemFillOnMouseOverBrush

public Brush TabItemFillOnMouseOverBrush

Gets or sets the tab item fill on mouse over brush.

Value. The tab item fill on mouse over brush.

TabItemPathBrush

public Brush TabItemPathBrush

Gets or sets the tab item path brush.

Value. The tab item path brush.

TabItemSelectedFill

public Brush TabItemSelectedFill

Gets or sets the tab item selected fill.

Value. The tab item selected fill.

TabItemTextForeground

public Brush TabItemTextForeground

Gets or sets the tab item text foreground.

Value. The tab item text foreground.

TabStripBackground

public Brush TabStripBackground

Gets or sets the brush painted behind the tab headers, including the scroll and add buttons. Null, the default, leaves the strip transparent so the parent shows through; set it when the parent is dark, because unselected tabs in the flat modes draw no fill of their own.

Methods

OnKeyDown

protected override void OnKeyDown(KeyEventArgs e)

Ctrl+F4 asks for the selected tab to be closed, as it closes a document in Windows applications.

e
The key.

Events

AddNewTabItemClick

public event RoutedEventHandler AddNewTabItemClick

Occurs when the add-new-tab button at the end of the tab strip is clicked.

The button is shown when IsAddNewTabItemButtonVisible is true. The control does not add a tab itself: handle this event and add a TabItem to Items, or an item to the bound collection.

Fields

AddNewItemButtonBackgroundProperty

public static readonly DependencyProperty AddNewItemButtonBackgroundProperty

The add new item button background property

AddNewItemContentBrushProperty

public static readonly DependencyProperty AddNewItemContentBrushProperty

The add new item content brush property

AddNewTabItemClickEvent

public static readonly RoutedEvent AddNewTabItemClickEvent

Identifies the AddNewTabItemClick routed event.

AddNewTabItemTooltipTextProperty

public static readonly DependencyProperty AddNewTabItemTooltipTextProperty

The add new tab item tooltip text property

ButtonLeftArrowGeometryPathFillBrushProperty

public static readonly DependencyProperty ButtonLeftArrowGeometryPathFillBrushProperty

The button left arrow geometry path fill brush property

ButtonLeftArrowGeometryPathStrokeBrushProperty

public static readonly DependencyProperty ButtonLeftArrowGeometryPathStrokeBrushProperty

The button left arrow geometry path stroke brush property

ButtonRightArrowGeometryPathFillBrushProperty

public static readonly DependencyProperty ButtonRightArrowGeometryPathFillBrushProperty

The button right arrow geometry path fill brush property

ButtonRightArrowGeometryPathStrokeBrushProperty

public static readonly DependencyProperty ButtonRightArrowGeometryPathStrokeBrushProperty

The button right arrow geometry path stroke brush property

CloseButtonCrossMarkColorBrushProperty

public static readonly DependencyProperty CloseButtonCrossMarkColorBrushProperty

The close button cross mark color brush property

CloseButtonStrokeBrushProperty

public static readonly DependencyProperty CloseButtonStrokeBrushProperty

The close button stroke brush property

CloseTabTooltipTextProperty

public static readonly DependencyProperty CloseTabTooltipTextProperty

The close tab tooltip text property

IsAddNewTabItemButtonVisibleProperty

public static readonly DependencyProperty IsAddNewTabItemButtonVisibleProperty

Identifies the IsAddNewTabItemButtonVisible dependency property.

RenderingModeProperty

public static readonly DependencyProperty RenderingModeProperty

The rendering mode property

ScrollButtonBrushProperty

public static readonly DependencyProperty ScrollButtonBrushProperty

The scroll button brush property

ScrollButtonOnMouseOverBrushProperty

public static readonly DependencyProperty ScrollButtonOnMouseOverBrushProperty

The scroll button on mouse over brush property

TabControlBackgroundProperty

public static readonly DependencyProperty TabControlBackgroundProperty

The tab control background property

TabItemAccentBrushProperty

public static readonly DependencyProperty TabItemAccentBrushProperty

Identifies the TabItemAccentBrush dependency property.

TabItemAccentForegroundProperty

public static readonly DependencyProperty TabItemAccentForegroundProperty

Identifies the TabItemAccentForeground dependency property.

TabItemBorderBrushProperty

public static readonly DependencyProperty TabItemBorderBrushProperty

The tab item border brush property

TabItemBorderOnMouseOverBrushProperty

public static readonly DependencyProperty TabItemBorderOnMouseOverBrushProperty

The tab item border on mouse over brush property

TabItemCloseButtonFillOnMouseOverBrushProperty

public static readonly DependencyProperty TabItemCloseButtonFillOnMouseOverBrushProperty

The tab item close button fill on mouse over brush property

TabItemControlTemplateProperty

public static readonly DependencyProperty TabItemControlTemplateProperty

The tab item control template property

TabItemFillOnMouseOverBrushProperty

public static readonly DependencyProperty TabItemFillOnMouseOverBrushProperty

The tab item fill on mouse over brush property

TabItemPathBrushProperty

public static readonly DependencyProperty TabItemPathBrushProperty

The tab item path brush property

TabItemSelectedFillProperty

public static readonly DependencyProperty TabItemSelectedFillProperty

The tab item selected fill property

TabItemTextForegroundProperty

public static readonly DependencyProperty TabItemTextForegroundProperty

The tab item text foreground property

TabStripBackgroundProperty

public static readonly DependencyProperty TabStripBackgroundProperty

Identifies the TabStripBackground dependency property.