Class TabControl
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
HorizontalContentAlignmentProperty
Defines the HorizontalContentAlignment property.
public static readonly StyledProperty<HorizontalAlignment> HorizontalContentAlignmentProperty
Field Value
SelectedContentProperty
The selected content property
public static readonly DirectProperty<TabControl, object?> SelectedContentProperty
Field Value
SelectedContentTemplateProperty
The selected content template property
public static readonly DirectProperty<TabControl, IDataTemplate?> SelectedContentTemplateProperty
Field Value
TabStripPlacementProperty
Defines the TabStripPlacement property.
public static readonly StyledProperty<Dock> TabStripPlacementProperty
Field Value
VerticalContentAlignmentProperty
Defines the VerticalContentAlignment property.
public static readonly StyledProperty<VerticalAlignment> VerticalContentAlignmentProperty
Field Value
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
HorizontalContentAlignment
Gets or sets the horizontal alignment of the content within the control.
public HorizontalAlignment HorizontalContentAlignment { get; set; }
Property Value
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
VerticalContentAlignment
Gets or sets the vertical alignment of the content within the control.
public VerticalAlignment VerticalContentAlignment { get; set; }
Property Value
Methods
ClearContainerForItemOverride(Control)
Undoes the effects of the PrepareContainerForItemOverride(Control, object?, int) method.
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
ControlThe container whose index changed.
oldIndex
intThe old index.
newIndex
intThe 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
Returns
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
objectThe item to check.
index
intThe index of the item.
recycleKey
objectWhen 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
TemplateAppliedEventArgsThe event args.
OnGotFocus(GotFocusEventArgs)
Called before the GotFocus event occurs.
protected override void OnGotFocus(GotFocusEventArgs e)
Parameters
e
GotFocusEventArgsThe event args.
OnPointerPressed(PointerPressedEventArgs)
Called before the PointerPressed event occurs.
protected override void OnPointerPressed(PointerPressedEventArgs e)
Parameters
e
PointerPressedEventArgsThe event args.
OnPointerReleased(PointerReleasedEventArgs)
Called before the PointerReleased event occurs.
protected override void OnPointerReleased(PointerReleasedEventArgs e)
Parameters
e
PointerReleasedEventArgsThe event args.
OnPropertyChanged(AvaloniaPropertyChangedEventArgs)
Called when a avalonia property changes on the object.
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
Parameters
change
AvaloniaPropertyChangedEventArgsThe 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
RegisterContentPresenter(ContentPresenter)
Called when an ContentPresenter is registered with the control.
protected virtual bool RegisterContentPresenter(ContentPresenter presenter)
Parameters
presenter
ContentPresenterThe presenter.