Class ContentPresenter
- Namespace
- Avalonia.Controls.Presenters
- Assembly
- Avalonia.Controls.dll
Presents a single item of data inside a TemplatedControl template.
[PseudoClasses(new string[] { ":empty" })]
public class ContentPresenter : Control, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue
- Inheritance
-
ContentPresenter
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
ContentPresenter()
public ContentPresenter()
Fields
BackgroundProperty
Defines the Background property.
public static readonly StyledProperty<IBrush?> BackgroundProperty
Field Value
BackgroundSizingProperty
Defines the BackgroundSizing property.
public static readonly StyledProperty<BackgroundSizing> BackgroundSizingProperty
Field Value
BorderBrushProperty
Defines the BorderBrush property.
public static readonly StyledProperty<IBrush?> BorderBrushProperty
Field Value
BorderThicknessProperty
Defines the BorderThickness property.
public static readonly StyledProperty<Thickness> BorderThicknessProperty
Field Value
BoxShadowProperty
Defines the BoxShadow property.
public static readonly StyledProperty<BoxShadows> BoxShadowProperty
Field Value
ChildProperty
Defines the Child property.
public static readonly DirectProperty<ContentPresenter, Control?> ChildProperty
Field Value
ContentProperty
Defines the Content property.
public static readonly StyledProperty<object?> ContentProperty
Field Value
ContentTemplateProperty
Defines the ContentTemplate property.
public static readonly StyledProperty<IDataTemplate?> ContentTemplateProperty
Field Value
CornerRadiusProperty
Defines the CornerRadius property.
public static readonly StyledProperty<CornerRadius> CornerRadiusProperty
Field Value
FontFamilyProperty
Defines the FontFamily property.
public static readonly StyledProperty<FontFamily> FontFamilyProperty
Field Value
FontSizeProperty
Defines the FontSize property.
public static readonly StyledProperty<double> FontSizeProperty
Field Value
FontStretchProperty
Defines the FontStretch property.
public static readonly StyledProperty<FontStretch> FontStretchProperty
Field Value
FontStyleProperty
Defines the FontStyle property.
public static readonly StyledProperty<FontStyle> FontStyleProperty
Field Value
FontWeightProperty
Defines the FontWeight property.
public static readonly StyledProperty<FontWeight> FontWeightProperty
Field Value
ForegroundProperty
Defines the Foreground property.
public static readonly StyledProperty<IBrush?> ForegroundProperty
Field Value
HorizontalContentAlignmentProperty
Defines the HorizontalContentAlignment property.
public static readonly StyledProperty<HorizontalAlignment> HorizontalContentAlignmentProperty
Field Value
LineHeightProperty
Defines the LineHeight property
public static readonly StyledProperty<double> LineHeightProperty
Field Value
MaxLinesProperty
Defines the MaxLines property
public static readonly StyledProperty<int> MaxLinesProperty
Field Value
PaddingProperty
Defines the Padding property.
public static readonly StyledProperty<Thickness> PaddingProperty
Field Value
RecognizesAccessKeyProperty
Defines the RecognizesAccessKey property
public static readonly StyledProperty<bool> RecognizesAccessKeyProperty
Field Value
TextAlignmentProperty
Defines the TextAlignment property
public static readonly StyledProperty<TextAlignment> TextAlignmentProperty
Field Value
TextTrimmingProperty
Defines the TextTrimming property
public static readonly StyledProperty<TextTrimming> TextTrimmingProperty
Field Value
TextWrappingProperty
Defines the TextWrapping property
public static readonly StyledProperty<TextWrapping> TextWrappingProperty
Field Value
VerticalContentAlignmentProperty
Defines the VerticalContentAlignment property.
public static readonly StyledProperty<VerticalAlignment> VerticalContentAlignmentProperty
Field Value
Properties
Background
Gets or sets a brush with which to paint the background.
public IBrush? Background { get; set; }
Property Value
BackgroundSizing
Gets or sets how the background is drawn relative to the border.
public BackgroundSizing BackgroundSizing { get; set; }
Property Value
BorderBrush
Gets or sets a brush with which to paint the border.
public IBrush? BorderBrush { get; set; }
Property Value
BorderThickness
Gets or sets the thickness of the border.
public Thickness BorderThickness { get; set; }
Property Value
BoxShadow
Gets or sets the box shadow effect parameters
public BoxShadows BoxShadow { get; set; }
Property Value
Child
Gets the control displayed by the presenter.
public Control? Child { get; }
Property Value
Content
Gets or sets the content to be displayed by the presenter.
[DependsOn("ContentTemplate")]
public object? Content { get; set; }
Property Value
ContentTemplate
Gets or sets the data template used to display the content of the control.
public IDataTemplate? ContentTemplate { get; set; }
Property Value
CornerRadius
Gets or sets the radius of the border rounded corners.
public CornerRadius CornerRadius { get; set; }
Property Value
FontFamily
Gets or sets the font family.
public FontFamily FontFamily { get; set; }
Property Value
FontSize
Gets or sets the font size.
public double FontSize { get; set; }
Property Value
FontStretch
Gets or sets the font stretch.
public FontStretch FontStretch { get; set; }
Property Value
FontStyle
Gets or sets the font style.
public FontStyle FontStyle { get; set; }
Property Value
FontWeight
Gets or sets the font weight.
public FontWeight FontWeight { get; set; }
Property Value
Foreground
Gets or sets a brush used to paint the text.
public IBrush? Foreground { get; set; }
Property Value
HorizontalContentAlignment
Gets or sets the horizontal alignment of the content within the border the control.
public HorizontalAlignment HorizontalContentAlignment { get; set; }
Property Value
LineHeight
Gets or sets the line height
public double LineHeight { get; set; }
Property Value
MaxLines
Gets or sets the max lines
public int MaxLines { get; set; }
Property Value
Padding
Gets or sets the space between the border and the Child control.
public Thickness Padding { get; set; }
Property Value
RecognizesAccessKey
Determine if ContentPresenter should use AccessText in its style
public bool RecognizesAccessKey { get; set; }
Property Value
TextAlignment
Gets or sets the text alignment
public TextAlignment TextAlignment { get; set; }
Property Value
TextTrimming
Gets or sets the text trimming
public TextTrimming TextTrimming { get; set; }
Property Value
TextWrapping
Gets or sets the text wrapping
public TextWrapping TextWrapping { get; set; }
Property Value
VerticalContentAlignment
Gets or sets the vertical alignment of the content within the border of the control.
public VerticalAlignment VerticalContentAlignment { get; set; }
Property Value
Methods
ApplyTemplate()
Creates the visual children of the control, if necessary
public override sealed void ApplyTemplate()
ArrangeOverride(Size)
Positions child elements as part of a layout pass.
protected override Size ArrangeOverride(Size finalSize)
Parameters
finalSize
SizeThe size available to the control.
Returns
- Size
The actual size used.
MeasureOverride(Size)
Measures the control and its child elements as part of a layout pass.
protected override Size MeasureOverride(Size availableSize)
Parameters
availableSize
SizeThe size available to the control.
Returns
- Size
The desired size for the control.
OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs)
Called when the styled element is added to a rooted logical tree.
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
Parameters
e
LogicalTreeAttachmentEventArgsThe 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.
Render(DrawingContext)
Renders the visual to a DrawingContext.
public override sealed void Render(DrawingContext context)
Parameters
context
DrawingContextThe drawing context.
UpdateChild()
public void UpdateChild()
Remarks
Usually the Child control is created automatically when ApplyTemplate() is called; however for this to happen, the control needs to be attached to a logical tree (if the control is not attached to the logical tree, it is reasonable to expect that the DataTemplates needed for the child are not yet available). This method forces the Child control's creation at any point, and is particularly useful in unit tests.