TextElement Class
Definition
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
Methods
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
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
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
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
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
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
| Name | Description |
|---|---|
| Background | Gets or sets a brush used to paint the control's background. |
| FontFamily | Gets or sets the font family. |
| FontFeatures | Gets or sets the font features. |
| FontSize | Gets or sets the font size. |
| FontStretch | Gets or sets the font stretch. |
| FontStyle | Gets or sets the font style. |
| FontWeight | Gets or sets the font weight. |
| Foreground | Gets or sets a brush used to paint the text. |
| LetterSpacing | Gets or sets the letter spacing. |
| ActualThemeVariant | Gets the UI theme that is currently used by the element, which might be different than the RequestedThemeVariantProperty. Inherited from StyledElement. |
| Classes | Gets or sets the styled element's classes. Inherited from StyledElement. |
| DataContext | Gets or sets the control's data context. Inherited from StyledElement. |
| IsInitialized | Gets a value that indicates whether the element has finished initialization. Inherited from StyledElement. |
| Name | Gets or sets the name of the styled element. Inherited from StyledElement. |
| Parent | Gets the styled element's logical parent. Inherited from StyledElement. |
| Resources | Gets or sets the styled element's resource dictionary. Inherited from StyledElement. |
| StyleKey | Gets the type by which the element is styled. Inherited from StyledElement. |
| Styles | Gets the styles for the styled element. Inherited from StyledElement. |
| TemplatedParent | Gets the styled element whose lookless template this styled element is part of. Inherited from StyledElement. |
| Theme | Gets or sets the theme to be applied to the element. Inherited from StyledElement. |
| Transitions | Gets or sets the property transitions for the control. Inherited from Animatable. |
| Dispatcher | Returns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with. Inherited from AvaloniaObject. |
| Item | Inherited 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
| Name | Description |
|---|---|
| ActualThemeVariantChanged | Raised when the theme variant is changed on the element or an ancestor of the element. Inherited from StyledElement. |
| AttachedToLogicalTree | Raised when the styled element is attached to a rooted logical tree. Inherited from StyledElement. |
| DataContextChanged | Occurs when the Avalonia.StyledElement.DataContext property changes. Inherited from StyledElement. |
| DetachedFromLogicalTree | Raised when the styled element is detached from a rooted logical tree. Inherited from StyledElement. |
| Initialized | Occurs when the styled element has finished initialization. Inherited from StyledElement. |
| ResourcesChanged | Occurs when a resource in this styled element or a parent styled element has changed. Inherited from StyledElement. |
| PropertyChanged | Raised when a Avalonia.AvaloniaProperty value changes on this object. Inherited from AvaloniaObject. |