Skip to content

TabControl

JaykeBird edited this page Feb 21, 2023 · 10 revisions

Back to home | Back to Reference | View raw text

TabControl class

Description

A control that can house multiple controls under a number of tabs. Each tab has a title, icon, and close button (see TabItem ).

Diagram

  flowchart LR
  classDef interfaceStyle stroke-dasharray: 5 5;
  classDef abstractStyle stroke-width:4px
  subgraph SolidShineUi
  SolidShineUi.TabControl[[TabControl]]
  end
  subgraph System.Windows.Controls
System.Windows.Controls.Control[[Control]]
  end
System.Windows.Controls.Control --> SolidShineUi.TabControl
Loading

Members

Properties

Public properties

Type Name Methods
bool AllowTabDragDrop
Get or set if tabs can be dragged and dropped.
get, set
ColorScheme ColorScheme
Get or set the color scheme to apply to the control. The color scheme can quickly apply a whole visual style to your control.
get, set
TabItem CurrentTab
Get the tab currently selected. Use Items.Select() to select another tab.
get
double HorizontalTabBarHeight
Get or set the height of the horizontal tab bar. The default value is 24.
get, set
SelectableCollection<TabItem> Items
Get or set the list of tabs in this TabControl. This Items property can be used to add tabs, remove tabs, and also select tabs via the Select method.
get
UIElement LeftTabBarElement
Get or set the element to display on the left side of the tab bar.
get, set
UIElement RightTabBarElement
Get or set the element to display on the right side of the tab bar (to the left of the Tab List Menu).
get, set
bool ScrollButtonsVisible
Get if the scroll buttons are currently visible in the tab bar.
get
bool SelectFirstTabOnLoad
Get or set if the first tab should be selected right away when the control is loaded. This property has no effect after the control is loaded.
get, set
TabItem SelectedTab
Get the tab currently selected. Use Items.Select() to select another tab.
get
SelectedTabCloseAction SelectedTabClosedAction
Get or set the action to take when the currently selected tab is closed.
get, set
UIElement SelectedTabContent
Get the currently shown content in the main part of the control. This is the content of the currently selected tab.
get
bool ShowTabListMenu
Get or set if a tab list menu should be shown on the far-right edge of the control's tab bar, listing all the open tabs. This mimics a similar menu found in Visual Studio.
get, set
bool ShowTabsOnBottom
Get or set if the tab bar should be shown at the bottom of the control, rather than the top.
get, set
double TabMinWidth
Get or set the minimum width a tab should have in the tab bar. While tabs may be wider than this width, they will never be shorter than it.
get, set

Methods

Public methods

Returns Name
void ApplyColorScheme(ColorScheme cs)
Apply a color scheme to this control. The color scheme can quickly apply a whole visual style to the control.
void CloseTab(TabItem tab)
Close a specific tab in this TabControl.

Protected internal methods

Returns Name
void SetupTabDisplay(TabDisplayItem tdi)
Set up a new TabDisplayItem that was added to this TabControl.
This will set up the necessary event handlers and other properties to allow the TabDisplayItem to interact with the TabControl.

Public Static methods

Returns Name
void OnColorSchemeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
Perform an action when the ColorScheme property has changed. Primarily used internally.

Details

Summary

A control that can house multiple controls under a number of tabs. Each tab has a title, icon, and close button (see TabItem ).

Inheritance

  • Control

Constructors

TabControl

public TabControl()
Summary

Create a TabControl.

Methods

CloseTab

public void CloseTab(TabItem tab)
Arguments
Type Name Description
TabItem tab The tab to close.
Summary

Close a specific tab in this TabControl.

Remarks

If tab is not in this TabControl, or if the tab closing is cancelled via the TabClosing event, then nothing will happen. This does not take the tab 's CanClose property into account; the tab will be closed regardless.

OnColorSchemeChanged

public static void OnColorSchemeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
Arguments
Type Name Description
DependencyObject d The object containing the property that changed.
DependencyPropertyChangedEventArgs e Event arguments about the property change.
Summary

Perform an action when the ColorScheme property has changed. Primarily used internally.

ApplyColorScheme

public void ApplyColorScheme(ColorScheme cs)
Arguments
Type Name Description
ColorScheme cs The color scheme to apply.
Summary

Apply a color scheme to this control. The color scheme can quickly apply a whole visual style to the control.

SetupTabDisplay

protected internal void SetupTabDisplay(TabDisplayItem tdi)
Arguments
Type Name Description
TabDisplayItem tdi The TabDisplayItem to set up.
Summary

Set up a new TabDisplayItem that was added to this TabControl. This will set up the necessary event handlers and other properties to allow the TabDisplayItem to interact with the TabControl.

Properties

SelectFirstTabOnLoad

public bool SelectFirstTabOnLoad { get; set; }
Summary

Get or set if the first tab should be selected right away when the control is loaded. This property has no effect after the control is loaded.

Items

public SelectableCollection<TabItem> Items { get; }
Summary

Get or set the list of tabs in this TabControl. This Items property can be used to add tabs, remove tabs, and also select tabs via the Select method.

SelectedTab

public TabItem SelectedTab { get; }
Summary

Get the tab currently selected. Use Items.Select() to select another tab.

SelectedTabContent

public UIElement SelectedTabContent { get; }
Summary

Get the currently shown content in the main part of the control. This is the content of the currently selected tab.

CurrentTab

public TabItem CurrentTab { get; }
Summary

Get the tab currently selected. Use Items.Select() to select another tab.

ShowTabsOnBottom

public bool ShowTabsOnBottom { get; set; }
Summary

Get or set if the tab bar should be shown at the bottom of the control, rather than the top.

HorizontalTabBarHeight

public double HorizontalTabBarHeight { get; set; }
Summary

Get or set the height of the horizontal tab bar. The default value is 24.

LeftTabBarElement

public UIElement LeftTabBarElement { get; set; }
Summary

Get or set the element to display on the left side of the tab bar.

RightTabBarElement

public UIElement RightTabBarElement { get; set; }
Summary

Get or set the element to display on the right side of the tab bar (to the left of the Tab List Menu).

ShowTabListMenu

public bool ShowTabListMenu { get; set; }
Summary

Get or set if a tab list menu should be shown on the far-right edge of the control's tab bar, listing all the open tabs. This mimics a similar menu found in Visual Studio.

TabMinWidth

public double TabMinWidth { get; set; }
Summary

Get or set the minimum width a tab should have in the tab bar. While tabs may be wider than this width, they will never be shorter than it.

SelectedTabClosedAction

public SelectedTabCloseAction SelectedTabClosedAction { get; set; }
Summary

Get or set the action to take when the currently selected tab is closed.

Remarks

Clearing the selection (via Items.ClearSelection or other methods) will trigger this action as well, meaning the TabControl will attempt to select another tab if this action is not SelectNothing . If you need to clear the selection, you'll need to set this property to SelectNothing first, clear the selection, and then reset this to whatever value you had previously (by default, the value is SelectTabToLeft ).

When a tab that isn't currently the selected tab is closed, that is not affected with this property.

AllowTabDragDrop

public bool AllowTabDragDrop { get; set; }
Summary

Get or set if tabs can be dragged and dropped.

Remarks

Note that dragging and dropping tabs between TabControls is not currently supported.

ColorScheme

public ColorScheme ColorScheme { get; set; }
Summary

Get or set the color scheme to apply to the control. The color scheme can quickly apply a whole visual style to your control.

ScrollButtonsVisible

public bool ScrollButtonsVisible { get; }
Summary

Get if the scroll buttons are currently visible in the tab bar.

Events

TabChanged

public event TabItemChangeEventHandler TabChanged
Summary

Raised when the tab currently selected is changed.

TabClosing

public event TabItemClosingEventHandler TabClosing
Summary

Raised when a tab is about to be closed, with the ability to cancel the action.

TabClosed

public event TabItemChangeEventHandler TabClosed
Summary

Raised when a tab is closed.

TabsCleared

public event EventHandler TabsCleared
Summary

Raised when all tabs are closed at once (via Items.Clear() ).

InternalShowTabsOnBottomChanged

protected event DependencyPropertyChangedEventHandler InternalShowTabsOnBottomChanged
Summary

Internal event for handling a property changed. Please view the event that is not prefixed as "Internal".

ShowTabsOnBottomChanged

public event DependencyPropertyChangedEventHandler ShowTabsOnBottomChanged
Summary

Raised when the ShowTabsOnBottom property is changed.

InternalHorizontalTabBarHeightChanged

protected event DependencyPropertyChangedEventHandler InternalHorizontalTabBarHeightChanged
Summary

Internal event for handling a property changed. Please view the event that is not prefixed as "Internal".

HorizontalTabBarHeightChanged

public event DependencyPropertyChangedEventHandler HorizontalTabBarHeightChanged
Summary

Raised when the HorizontalTabBarHeight property is changed.

InternalShowTabListMenuChanged

protected event DependencyPropertyChangedEventHandler InternalShowTabListMenuChanged
Summary

Internal event for handling a property changed. Please view the event that is not prefixed as "Internal".

ShowTabListMenuChanged

public event DependencyPropertyChangedEventHandler ShowTabListMenuChanged
Summary

Raised when the ShowTabListMenu property is changed.

InternalTabMinWidthChanged

protected event DependencyPropertyChangedEventHandler InternalTabMinWidthChanged
Summary

Internal event for handling a property changed. Please view the event that is not prefixed as "Internal".

TabMinWidthChanged

public event DependencyPropertyChangedEventHandler TabMinWidthChanged
Summary

Raised when the TabMinWidth property is changed.

InternalAllowTabDragDropChanged

protected event DependencyPropertyChangedEventHandler InternalAllowTabDragDropChanged
Summary

Internal event for handling a property changed. Please view the event that is not prefixed as "Internal".

AllowTabDragDropChanged

public event DependencyPropertyChangedEventHandler AllowTabDragDropChanged
Summary

Raised when the AllowTabDragDrop property is changed.

Delegates

TabItemChangeEventHandler

public delegate void TabItemChangeEventHandler(object sender, TabItemChangeEventArgs e)
Arguments
Type Name Description
object sender
TabItemChangeEventArgs e

TabItemClosingEventHandler

public delegate void TabItemClosingEventHandler(object sender, TabItemClosingEventArgs e)
Arguments
Type Name Description
object sender
TabItemClosingEventArgs e

Generated with ModularDoc

Clone this wiki locally