Skip to main content

TextElement Class

Definition

Assembly:Avalonia.Controls
Package:Avalonia

TextElement is an base class for content in text based controls. TextElements span other content, applying property values or providing structural information.

public class TextElement

Inheritance: object -> AvaloniaObject -> Animatable -> StyledElement -> TextElement

Derived types:Inline

Methods

NameDescription
GetFontFamilyGets the value of the attached Avalonia.Controls.Documents.TextElement.FontFamilyProperty on a control.
GetFontFeaturesGets the value of the attached Avalonia.Controls.Documents.TextElement.FontFeaturesProperty on a control.
GetFontSizeGets the value of the attached Avalonia.Controls.Documents.TextElement.FontSizeProperty on a control.
GetFontStretchGets the value of the attached Avalonia.Controls.Documents.TextElement.FontStretchProperty on a control.
GetFontStyleGets the value of the attached Avalonia.Controls.Documents.TextElement.FontStyleProperty on a control.
GetFontWeightGets the value of the attached Avalonia.Controls.Documents.TextElement.FontWeightProperty on a control.
GetForegroundGets the value of the attached Avalonia.Controls.Documents.TextElement.ForegroundProperty on a control.
GetLetterSpacingGets the value of the attached Avalonia.Controls.Documents.TextElement.LetterSpacingProperty on a control.
SetFontFamilySets the value of the attached Avalonia.Controls.Documents.TextElement.FontFamilyProperty on a control.
SetFontFeaturesSets the value of the attached Avalonia.Controls.Documents.TextElement.FontFeaturesProperty on a control.
SetFontSizeSets the value of the attached Avalonia.Controls.Documents.TextElement.FontSizeProperty on a control.
SetFontStretchSets the value of the attached Avalonia.Controls.Documents.TextElement.FontStretchProperty on a control.
SetFontStyleSets the value of the attached Avalonia.Controls.Documents.TextElement.FontStyleProperty on a control.
SetFontWeightSets the value of the attached Avalonia.Controls.Documents.TextElement.FontWeightProperty on a control.
SetForegroundSets the value of the attached Avalonia.Controls.Documents.TextElement.ForegroundProperty on a control.
SetLetterSpacingSets the value of the attached Avalonia.Controls.Documents.TextElement.LetterSpacingProperty on a control.
ApplyStylingApplies styling to the control if the control is initialized and styling is not already applied. Inherited from StyledElement.
BeginInitInherited from StyledElement.
EndInitInherited from StyledElement.
TryGetResourceInherited from StyledElement.
Bind (8 overloads)Binds a Avalonia.AvaloniaProperty to an Avalonia.Data.BindingBase. Inherited from AvaloniaObject.
CheckAccessReturns a value indicating whether the current thread is the UI thread. Inherited from AvaloniaObject.
ClearValue (4 overloads)Clears a Avalonia.AvaloniaProperty's local value. Inherited from AvaloniaObject.
CoerceValueCoerces the specified Avalonia.AvaloniaProperty. Inherited from AvaloniaObject.
EqualsCompares two objects using reference equality. Inherited from AvaloniaObject.
GetBaseValueInherited from AvaloniaObject.
GetHashCodeGets the hash code for the object. Inherited from AvaloniaObject.
GetValue (3 overloads)Gets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject.
IsAnimatingChecks whether a Avalonia.AvaloniaProperty is animating. Inherited from AvaloniaObject.
IsSetChecks whether a Avalonia.AvaloniaProperty is set on this object. Inherited from AvaloniaObject.
SetCurrentValue (2 overloads)Sets the value of a dependency property without changing its value source. Inherited from AvaloniaObject.
SetValue (3 overloads)Sets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject.
VerifyAccessChecks that the current thread is the UI thread and throws if not. Inherited from AvaloniaObject.

GetFontFamily Method

Gets the value of the attached Avalonia.Controls.Documents.TextElement.FontFamilyProperty on a control.

public Avalonia.Media.FontFamily GetFontFamily(Avalonia.Controls.Control control)

Parameters

control Avalonia.Controls.Control

The control.

Returns

Avalonia.Media.FontFamily

The font family.

GetFontFeatures Method

Gets the value of the attached Avalonia.Controls.Documents.TextElement.FontFeaturesProperty on a control.

public Avalonia.Media.FontFeatureCollection GetFontFeatures(Avalonia.Controls.Control control)

Parameters

control Avalonia.Controls.Control

The control.

Returns

Avalonia.Media.FontFeatureCollection

The font family.

GetFontSize Method

Gets the value of the attached Avalonia.Controls.Documents.TextElement.FontSizeProperty on a control.

public double GetFontSize(Avalonia.Controls.Control control)

Parameters

control Avalonia.Controls.Control

The control.

Returns

double

The font size.

GetFontStretch Method

Gets the value of the attached Avalonia.Controls.Documents.TextElement.FontStretchProperty on a control.

public Avalonia.Media.FontStretch GetFontStretch(Avalonia.Controls.Control control)

Parameters

control Avalonia.Controls.Control

The control.

Returns

Avalonia.Media.FontStretch

The font stretch.

GetFontStyle Method

Gets the value of the attached Avalonia.Controls.Documents.TextElement.FontStyleProperty on a control.

public Avalonia.Media.FontStyle GetFontStyle(Avalonia.Controls.Control control)

Parameters

control Avalonia.Controls.Control

The control.

Returns

Avalonia.Media.FontStyle

The font style.

GetFontWeight Method

Gets the value of the attached Avalonia.Controls.Documents.TextElement.FontWeightProperty on a control.

public Avalonia.Media.FontWeight GetFontWeight(Avalonia.Controls.Control control)

Parameters

control Avalonia.Controls.Control

The control.

Returns

Avalonia.Media.FontWeight

The font weight.

GetForeground Method

Gets the value of the attached Avalonia.Controls.Documents.TextElement.ForegroundProperty on a control.

public Avalonia.Media.IBrush GetForeground(Avalonia.Controls.Control control)

Parameters

control Avalonia.Controls.Control

The control.

Returns

Avalonia.Media.IBrush

The foreground.

GetLetterSpacing Method

Gets the value of the attached Avalonia.Controls.Documents.TextElement.LetterSpacingProperty on a control.

public double GetLetterSpacing(Avalonia.Controls.Control control)

Parameters

control Avalonia.Controls.Control

The control.

Returns

double

The letter spacing applied to the control.

SetFontFamily Method

Sets the value of the attached Avalonia.Controls.Documents.TextElement.FontFamilyProperty on a control.

public void SetFontFamily(Avalonia.Controls.Control control, Avalonia.Media.FontFamily value)

Parameters

control Avalonia.Controls.Control

The control.

value Avalonia.Media.FontFamily

The property value to set.

SetFontFeatures Method

Sets the value of the attached Avalonia.Controls.Documents.TextElement.FontFeaturesProperty on a control.

public void SetFontFeatures(Avalonia.Controls.Control control, Avalonia.Media.FontFeatureCollection value)

Parameters

control Avalonia.Controls.Control

The control.

value Avalonia.Media.FontFeatureCollection

The property value to set.

SetFontSize Method

Sets the value of the attached Avalonia.Controls.Documents.TextElement.FontSizeProperty on a control.

public void SetFontSize(Avalonia.Controls.Control control, double value)

Parameters

control Avalonia.Controls.Control

The control.

value double

The property value to set.

SetFontStretch Method

Sets the value of the attached Avalonia.Controls.Documents.TextElement.FontStretchProperty on a control.

public void SetFontStretch(Avalonia.Controls.Control control, Avalonia.Media.FontStretch value)

Parameters

control Avalonia.Controls.Control

The control.

value Avalonia.Media.FontStretch

The property value to set.

SetFontStyle Method

Sets the value of the attached Avalonia.Controls.Documents.TextElement.FontStyleProperty on a control.

public void SetFontStyle(Avalonia.Controls.Control control, Avalonia.Media.FontStyle value)

Parameters

control Avalonia.Controls.Control

The control.

value Avalonia.Media.FontStyle

The property value to set.

SetFontWeight Method

Sets the value of the attached Avalonia.Controls.Documents.TextElement.FontWeightProperty on a control.

public void SetFontWeight(Avalonia.Controls.Control control, Avalonia.Media.FontWeight value)

Parameters

control Avalonia.Controls.Control

The control.

value Avalonia.Media.FontWeight

The property value to set.

SetForeground Method

Sets the value of the attached Avalonia.Controls.Documents.TextElement.ForegroundProperty on a control.

public void SetForeground(Avalonia.Controls.Control control, Avalonia.Media.IBrush value)

Parameters

control Avalonia.Controls.Control

The control.

value Avalonia.Media.IBrush

The property value to set.

SetLetterSpacing Method

Sets the value of the attached Avalonia.Controls.Documents.TextElement.LetterSpacingProperty on a control.

public void SetLetterSpacing(Avalonia.Controls.Control control, double value)

Parameters

control Avalonia.Controls.Control

The control.

value double

The letter spacing to apply.

Properties

NameDescription
BackgroundGets or sets a brush used to paint the control's background.
FontFamilyGets or sets the font family.
FontFeaturesGets or sets the font features.
FontSizeGets or sets the font size.
FontStretchGets or sets the font stretch.
FontStyleGets or sets the font style.
FontWeightGets or sets the font weight.
ForegroundGets or sets a brush used to paint the text.
LetterSpacingGets or sets the letter spacing.
ActualThemeVariantGets the UI theme that is currently used by the element, which might be different than the RequestedThemeVariantProperty. Inherited from StyledElement.
ClassesGets or sets the styled element's classes. Inherited from StyledElement.
DataContextGets or sets the control's data context. Inherited from StyledElement.
IsInitializedGets a value that indicates whether the element has finished initialization. Inherited from StyledElement.
NameGets or sets the name of the styled element. Inherited from StyledElement.
ParentGets the styled element's logical parent. Inherited from StyledElement.
ResourcesGets or sets the styled element's resource dictionary. Inherited from StyledElement.
StyleKeyGets the type by which the element is styled. Inherited from StyledElement.
StylesGets the styles for the styled element. Inherited from StyledElement.
TemplatedParentGets the styled element whose lookless template this styled element is part of. Inherited from StyledElement.
ThemeGets or sets the theme to be applied to the element. Inherited from StyledElement.
TransitionsGets or sets the property transitions for the control. Inherited from Animatable.
DispatcherReturns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with. Inherited from AvaloniaObject.
ItemInherited from AvaloniaObject.

Background Property

Gets or sets a brush used to paint the control's background.

public Avalonia.Media.IBrush Background { get; set; }

FontFamily Property

Gets or sets the font family.

public Avalonia.Media.FontFamily FontFamily { get; set; }

FontFeatures Property

Gets or sets the font features.

public Avalonia.Media.FontFeatureCollection FontFeatures { get; set; }

FontSize Property

Gets or sets the font size.

public double FontSize { get; set; }

FontStretch Property

Gets or sets the font stretch.

public Avalonia.Media.FontStretch FontStretch { get; set; }

FontStyle Property

Gets or sets the font style.

public Avalonia.Media.FontStyle FontStyle { get; set; }

FontWeight Property

Gets or sets the font weight.

public Avalonia.Media.FontWeight FontWeight { get; set; }

Foreground Property

Gets or sets a brush used to paint the text.

public Avalonia.Media.IBrush Foreground { get; set; }

LetterSpacing Property

Gets or sets the letter spacing.

public double LetterSpacing { get; set; }

Fields

BackgroundProperty Field

Defines the Avalonia.Controls.Documents.TextElement.Background property.

public Avalonia.StyledProperty<Avalonia.Media.IBrush> BackgroundProperty

FontFamilyProperty Field

Defines the Avalonia.Controls.Documents.TextElement.FontFamily property.

public Avalonia.AttachedProperty<Avalonia.Media.FontFamily> FontFamilyProperty

FontFeaturesProperty Field

Defines the Avalonia.Controls.Documents.TextElement.FontFeatures property.

public Avalonia.AttachedProperty<Avalonia.Media.FontFeatureCollection> FontFeaturesProperty

FontSizeProperty Field

Defines the Avalonia.Controls.Documents.TextElement.FontSize property.

public Avalonia.AttachedProperty<double> FontSizeProperty

FontStretchProperty Field

Defines the Avalonia.Controls.Documents.TextElement.FontStretch property.

public Avalonia.AttachedProperty<Avalonia.Media.FontStretch> FontStretchProperty

FontStyleProperty Field

Defines the Avalonia.Controls.Documents.TextElement.FontStyle property.

public Avalonia.AttachedProperty<Avalonia.Media.FontStyle> FontStyleProperty

FontWeightProperty Field

Defines the Avalonia.Controls.Documents.TextElement.FontWeight property.

public Avalonia.AttachedProperty<Avalonia.Media.FontWeight> FontWeightProperty

ForegroundProperty Field

Defines the Avalonia.Controls.Documents.TextElement.Foreground property.

public Avalonia.AttachedProperty<Avalonia.Media.IBrush> ForegroundProperty

LetterSpacingProperty Field

Defines the Avalonia.Controls.Documents.TextElement.LetterSpacing property.

public Avalonia.AttachedProperty<double> LetterSpacingProperty

Remarks

This is an inherited attached property that defines letter spacing for text. Letter spacing is specified in pixels. Default value is 0 (normal spacing). Positive values increase spacing between characters. Negative values decrease spacing between characters.

Events

NameDescription
ActualThemeVariantChangedRaised when the theme variant is changed on the element or an ancestor of the element. Inherited from StyledElement.
AttachedToLogicalTreeRaised when the styled element is attached to a rooted logical tree. Inherited from StyledElement.
DataContextChangedOccurs when the Avalonia.StyledElement.DataContext property changes. Inherited from StyledElement.
DetachedFromLogicalTreeRaised when the styled element is detached from a rooted logical tree. Inherited from StyledElement.
InitializedOccurs when the styled element has finished initialization. Inherited from StyledElement.
ResourcesChangedOccurs when a resource in this styled element or a parent styled element has changed. Inherited from StyledElement.
PropertyChangedRaised when a Avalonia.AvaloniaProperty value changes on this object. Inherited from AvaloniaObject.