Table of Contents

Class TabControl

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll

A tab control that displays a tab strip along with the content of the selected tab.

[TemplatePart("PART_ItemsPresenter", typeof(ItemsPresenter))]
[TemplatePart("PART_SelectedContentHost", typeof(ContentPresenter))]
public class TabControl : SelectingItemsControl, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, IChildIndexProvider
Inheritance
TabControl
Implements
Inherited Members
Extension Methods

Constructors

TabControl()

public TabControl()

Fields

ContentTemplateProperty

Defines the ContentTemplate property.

public static readonly StyledProperty<IDataTemplate?> ContentTemplateProperty

Field Value

StyledProperty<IDataTemplate>

HorizontalContentAlignmentProperty

Defines the HorizontalContentAlignment property.

public static readonly StyledProperty<HorizontalAlignment> HorizontalContentAlignmentProperty

Field Value

StyledProperty<HorizontalAlignment>

SelectedContentProperty

The selected content property

public static readonly DirectProperty<TabControl, object?> SelectedContentProperty

Field Value

DirectProperty<TabControl, object>

SelectedContentTemplateProperty

The selected content template property

public static readonly DirectProperty<TabControl, IDataTemplate?> SelectedContentTemplateProperty

Field Value

DirectProperty<TabControl, IDataTemplate>

TabStripPlacementProperty

Defines the TabStripPlacement property.

public static readonly StyledProperty<Dock> TabStripPlacementProperty

Field Value

StyledProperty<Dock>

VerticalContentAlignmentProperty

Defines the VerticalContentAlignment property.

public static readonly StyledProperty<VerticalAlignment> VerticalContentAlignmentProperty

Field Value

StyledProperty<VerticalAlignment>

Properties

ContentTemplate

Gets or sets the default data template used to display the content of the selected tab.

public IDataTemplate? ContentTemplate { get; set; }

Property Value

IDataTemplate

HorizontalContentAlignment

Gets or sets the horizontal alignment of the content within the control.

public HorizontalAlignment HorizontalContentAlignment { get; set; }

Property Value

HorizontalAlignment

SelectedContent

Gets or sets the content of the selected tab.

public object? SelectedContent { get; }

Property Value

object

The content of the selected tab.

SelectedContentTemplate

Gets or sets the content template for the selected tab.

public IDataTemplate? SelectedContentTemplate { get; }

Property Value

IDataTemplate

The content template of the selected tab.

TabStripPlacement

Gets or sets the tabstrip placement of the TabControl.

public Dock TabStripPlacement { get; set; }

Property Value

Dock

VerticalContentAlignment

Gets or sets the vertical alignment of the content within the control.

public VerticalAlignment VerticalContentAlignment { get; set; }

Property Value

VerticalAlignment

Methods

ClearContainerForItemOverride(Control)

protected override void ClearContainerForItemOverride(Control element)

Parameters

element Control

ContainerIndexChangedOverride(Control, int, int)

Called when the index for a container changes due to an insertion or removal in the items collection.

protected override void ContainerIndexChangedOverride(Control container, int oldIndex, int newIndex)

Parameters

container Control

The container whose index changed.

oldIndex int

The old index.

newIndex int

The new index.

CreateContainerForItemOverride(object?, int, object?)

Creates or a container that can be used to display an item.

protected override Control CreateContainerForItemOverride(object? item, int index, object? recycleKey)

Parameters

item object
index int
recycleKey object

Returns

Control

NeedsContainerOverride(object?, int, out object?)

Determines whether the specified item can be its own container.

protected override bool NeedsContainerOverride(object? item, int index, out object? recycleKey)

Parameters

item object

The item to check.

index int

The index of the item.

recycleKey object

When the method returns, contains a key that can be used to locate a previously recycled container of the correct type, or null if the item cannot be recycled. If the item is its own container then by definition it cannot be recycled, so recycleKey shoud be set to null.

Returns

bool

true if the item needs a container; otherwise false if the item can itself be used as a container.

OnApplyTemplate(TemplateAppliedEventArgs)

Called when the control's template is applied. In simple terms, this means the method is called just before the control is displayed.

protected override void OnApplyTemplate(TemplateAppliedEventArgs e)

Parameters

e TemplateAppliedEventArgs

The event args.

OnGotFocus(GotFocusEventArgs)

Called before the GotFocus event occurs.

protected override void OnGotFocus(GotFocusEventArgs e)

Parameters

e GotFocusEventArgs

The event args.

OnPointerPressed(PointerPressedEventArgs)

Called before the PointerPressed event occurs.

protected override void OnPointerPressed(PointerPressedEventArgs e)

Parameters

e PointerPressedEventArgs

The event args.

OnPointerReleased(PointerReleasedEventArgs)

Called before the PointerReleased event occurs.

protected override void OnPointerReleased(PointerReleasedEventArgs e)

Parameters

e PointerReleasedEventArgs

The event args.

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.

PrepareContainerForItemOverride(Control, object?, int)

Prepares the specified element to display the specified item.

protected override void PrepareContainerForItemOverride(Control element, object? item, int index)

Parameters

element Control
item object

The item to display.

index int

The index of the item to display.

RegisterContentPresenter(ContentPresenter)

Called when an ContentPresenter is registered with the control.

protected virtual bool RegisterContentPresenter(ContentPresenter presenter)

Parameters

presenter ContentPresenter

The presenter.

Returns

bool