Skip to main content

RichTextElement Class

Definition​

Assembly:Avalonia.Controls.Documents
Package:Avalonia.Controls.Documents

Base class for rich text elements that participate in a TextDocument.

public class RichTextElement

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

Implements: ck, cn

Methods​

NameDescription
ApplyStylingApplies styling to the control if the control is initialized and styling is not already applied. Inherited from StyledElement.
BeginInitInherited 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.
EndInitInherited from StyledElement.
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.
TryGetResourceInherited from StyledElement.
VerifyAccessChecks that the current thread is the UI thread and throws if not. Inherited from AvaloniaObject.

Properties​

NameDescription
ActualThemeVariantGets the UI theme that is currently used by the element, which might be different than the RequestedThemeVariantProperty. Inherited from StyledElement.
BackgroundGets or sets the brush used to fill the background of the control.
ClassesGets or sets the styled element's classes. Inherited from StyledElement.
ContentEndGets a text pointer to the end of the content in the document.
ContentLengthGets the length, in characters, that is covered by this element.
ContentRangeGets the range of text that represents the entire content, or null if the content is empty or unavailable.
ContentStartGets a text pointer to the start of the content in the document.
DataContextGets or sets the control's data context. Inherited from StyledElement.
DispatcherReturns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with. Inherited from AvaloniaObject.
FirstChildElementGets the first direct child element in the document tree, or if none exists.
FontFamilyGets or sets the font family used to display text.
FontFeaturesGets or sets the collection of font features to apply to the text.
FontSizeGets or sets the size of the font used to display text.
FontStretchGets or sets the degree to which the font is stretched horizontally.
FontStyleGets or sets the font style used to display the text.
FontWeightGets or sets the weight or thickness of the font used to display text.
ForegroundGets or sets the brush used to paint the foreground of the control.
IsAttachedToDocumentGets a value indicating whether this element is currently attached to a Avalonia.Controls.Documents.TextModel.TextDocument.
IsInitializedGets a value that indicates whether the element has finished initialization. Inherited from StyledElement.
ItemInherited from AvaloniaObject.
LastChildElementGets the last direct child element in the document tree, or if none exists.
LetterSpacingGets or sets the letter spacing.
NameGets or sets the name of the styled element. Inherited from StyledElement.
NextElementGets the next sibling element in the document tree, or if none exists.
ParentGets the styled element's logical parent. Inherited from StyledElement.
PreviousElementGets the previous sibling element in the document tree, or if none exists.
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.
TextDocumentGets the Avalonia.Controls.Documents.TextModel.TextDocument this element is attached to, or if not attached.
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.

Background Property​

Gets or sets the brush used to fill the background of the control.

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

ContentEnd Property​

Gets a text pointer to the end of the content in the document.

public Avalonia.Controls.Documents.TextModel.TextPointer ContentEnd { get; set; }

Remarks​

The returned pointer refers to the position immediately following the last symbol in the element's content. Returns null if the element is not attached.

Returns the element's cached pointer instance. See Avalonia.Controls.Documents.RichTextElement.ContentStart for the cloning requirement.

ContentLength Property​

Gets the length, in characters, that is covered by this element.

public int ContentLength { get; set; }

ContentRange Property​

Gets the range of text that represents the entire content, or null if the content is empty or unavailable.

public Avalonia.Controls.Documents.TextModel.TextRange ContentRange { get; set; }

ContentStart Property​

Gets a text pointer to the start of the content in the document.

public Avalonia.Controls.Documents.TextModel.TextPointer ContentStart { get; set; }

Remarks​

If the element is not attached to a document, returns null.

Returns the element's cached pointer instance, not a fresh allocation. Callers that store the result in a mutable container (e.g. Avalonia.Controls.Documents.TextModel.TextRange endpoints, undo records) must call Avalonia.Controls.Documents.TextModel.TextPointer.Clone first; otherwise a later UpdateInPlace/Refresh through that container will shift the element's cached origin pointer and corrupt every future Avalonia.Controls.Documents.RichTextElement.ContentStart/Avalonia.Controls.Documents.RichTextElement.ContentRange read at the current generation. Avalonia.Controls.Documents.TextModel.TextRange's constructors and SetPositions already perform this clone automatically.

FirstChildElement Property​

Gets the first direct child element in the document tree, or if none exists.

public Avalonia.Controls.Documents.RichTextElement FirstChildElement { get; set; }

FontFamily Property​

Gets or sets the font family used to display text.

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

FontFeatures Property​

Gets or sets the collection of font features to apply to the text.

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

Remarks​

Font features allow customization of typographic presentation, such as enabling ligatures, alternate glyphs, or stylistic sets. If the value is null, the default font features are used.

FontSize Property​

Gets or sets the size of the font used to display text.

public double FontSize { get; set; }

FontStretch Property​

Gets or sets the degree to which the font is stretched horizontally.

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

FontStyle Property​

Gets or sets the font style used to display the text.

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

FontWeight Property​

Gets or sets the weight or thickness of the font used to display text.

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

Foreground Property​

Gets or sets the brush used to paint the foreground of the control.

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

IsAttachedToDocument Property​

Gets a value indicating whether this element is currently attached to a Avalonia.Controls.Documents.TextModel.TextDocument.

public bool IsAttachedToDocument { get; set; }

LastChildElement Property​

Gets the last direct child element in the document tree, or if none exists.

public Avalonia.Controls.Documents.RichTextElement LastChildElement { get; set; }

LetterSpacing Property​

Gets or sets the letter spacing.

public double LetterSpacing { get; set; }

NextElement Property​

Gets the next sibling element in the document tree, or if none exists.

public Avalonia.Controls.Documents.RichTextElement NextElement { get; set; }

PreviousElement Property​

Gets the previous sibling element in the document tree, or if none exists.

public Avalonia.Controls.Documents.RichTextElement PreviousElement { get; set; }

TextDocument Property​

Gets the Avalonia.Controls.Documents.TextModel.TextDocument this element is attached to, or if not attached.

public Avalonia.Controls.Documents.TextModel.TextDocument TextDocument { get; set; }

Fields​

BackgroundProperty Field​

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

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

Remarks​

Not inherited via the Avalonia property system. Background inheritance for inline elements is resolved manually during rendering so that a background set on a Avalonia.Controls.Documents.RichSpan propagates to its child inlines without leaking across block boundaries.

FontFamilyProperty Field​

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

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

FontFeaturesProperty Field​

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

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

FontSizeProperty Field​

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

public Avalonia.AttachedProperty<double> FontSizeProperty

FontStretchProperty Field​

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

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

FontStyleProperty Field​

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

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

FontWeightProperty Field​

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

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

ForegroundProperty Field​

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

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

LetterSpacingProperty Field​

Defines the Avalonia.Controls.Documents.RichTextElement.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.
PropertyChangedRaised when a Avalonia.AvaloniaProperty value changes on this object. Inherited from AvaloniaObject.
ResourcesChangedOccurs when a resource in this styled element or a parent styled element has changed. Inherited from StyledElement.