Table of Contents

Class ContentControl

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll

Displays Content according to an IDataTemplate.

[TemplatePart("PART_ContentPresenter", typeof(ContentPresenter))]
public class ContentControl : TemplatedControl, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue
Inheritance
ContentControl
Implements
Derived
Inherited Members
Extension Methods

Constructors

ContentControl()

public ContentControl()

Fields

ContentProperty

Defines the Content property.

public static readonly StyledProperty<object?> ContentProperty

Field Value

StyledProperty<object>

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>

VerticalContentAlignmentProperty

Defines the VerticalContentAlignment property.

public static readonly StyledProperty<VerticalAlignment> VerticalContentAlignmentProperty

Field Value

StyledProperty<VerticalAlignment>

Properties

Content

Gets or sets the content to display.

[Content]
[DependsOn("ContentTemplate")]
public object? Content { get; set; }

Property Value

object

ContentTemplate

Gets or sets the data template used to display the content of the control.

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

Presenter

Gets the presenter from the control's template.

public ContentPresenter? Presenter { get; }

Property Value

ContentPresenter

VerticalContentAlignment

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

public VerticalAlignment VerticalContentAlignment { get; set; }

Property Value

VerticalAlignment

Methods

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.

RegisterContentPresenter(ContentPresenter)

Called when an ContentPresenter is registered with the control.

protected virtual bool RegisterContentPresenter(ContentPresenter presenter)

Parameters

presenter ContentPresenter

The presenter.

Returns

bool