RichTextElement Class
Definition
Base class for rich text elements that participate in a TextDocument.
public class RichTextElement
Methods
| Name | Description |
|---|---|
| ApplyStyling | Applies styling to the control if the control is initialized and styling is not already applied. Inherited from StyledElement. |
| BeginInit | Inherited from StyledElement. |
| Bind (8 overloads) | Binds a Avalonia.AvaloniaProperty to an Avalonia.Data.BindingBase. Inherited from AvaloniaObject. |
| CheckAccess | Returns 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. |
| CoerceValue | Coerces the specified Avalonia.AvaloniaProperty. Inherited from AvaloniaObject. |
| EndInit | Inherited from StyledElement. |
| Equals | Compares two objects using reference equality. Inherited from AvaloniaObject. |
| GetBaseValue | Inherited from AvaloniaObject. |
| GetHashCode | Gets the hash code for the object. Inherited from AvaloniaObject. |
| GetValue (3 overloads) | Gets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject. |
| IsAnimating | Checks whether a Avalonia.AvaloniaProperty is animating. Inherited from AvaloniaObject. |
| IsSet | Checks 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. |
| TryGetResource | Inherited from StyledElement. |
| VerifyAccess | Checks that the current thread is the UI thread and throws if not. Inherited from AvaloniaObject. |
Properties
| Name | Description |
|---|---|
| ActualThemeVariant | Gets the UI theme that is currently used by the element, which might be different than the RequestedThemeVariantProperty. Inherited from StyledElement. |
| Background | Gets or sets the brush used to fill the background of the control. |
| Classes | Gets or sets the styled element's classes. Inherited from StyledElement. |
| ContentEnd | Gets a text pointer to the end of the content in the document. |
| ContentLength | Gets the length, in characters, that is covered by this element. |
| ContentRange | Gets the range of text that represents the entire content, or null if the content is empty or unavailable. |
| ContentStart | Gets a text pointer to the start of the content in the document. |
| DataContext | Gets or sets the control's data context. Inherited from StyledElement. |
| Dispatcher | Returns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with. Inherited from AvaloniaObject. |
| FirstChildElement | Gets the first direct child element in the document tree, or if none exists. |
| FontFamily | Gets or sets the font family used to display text. |
| FontFeatures | Gets or sets the collection of font features to apply to the text. |
| FontSize | Gets or sets the size of the font used to display text. |
| FontStretch | Gets or sets the degree to which the font is stretched horizontally. |
| FontStyle | Gets or sets the font style used to display the text. |
| FontWeight | Gets or sets the weight or thickness of the font used to display text. |
| Foreground | Gets or sets the brush used to paint the foreground of the control. |
| IsAttachedToDocument | Gets a value indicating whether this element is currently attached to a Avalonia.Controls.Documents.TextModel.TextDocument. |
| IsInitialized | Gets a value that indicates whether the element has finished initialization. Inherited from StyledElement. |
| Item | Inherited from AvaloniaObject. |
| LastChildElement | Gets the last direct child element in the document tree, or if none exists. |
| LetterSpacing | Gets or sets the letter spacing. |
| Name | Gets or sets the name of the styled element. Inherited from StyledElement. |
| NextElement | Gets the next sibling element in the document tree, or if none exists. |
| Parent | Gets the styled element's logical parent. Inherited from StyledElement. |
| PreviousElement | Gets the previous sibling element in the document tree, or if none exists. |
| 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. |
| TextDocument | Gets the Avalonia.Controls.Documents.TextModel.TextDocument this element is attached to, or if not attached. |
| 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. |
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
| 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. |
| PropertyChanged | Raised when a Avalonia.AvaloniaProperty value changes on this object. Inherited from AvaloniaObject. |
| ResourcesChanged | Occurs when a resource in this styled element or a parent styled element has changed. Inherited from StyledElement. |