Class TextPresenter
- Namespace
- Avalonia.Controls.Presenters
- Assembly
- Avalonia.Controls.dll
public class TextPresenter : Control, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue
- Inheritance
-
TextPresenter
- Implements
- Inherited Members
- Extension Methods
Constructors
TextPresenter()
public TextPresenter()
Fields
BackgroundProperty
Defines the Background property.
public static readonly StyledProperty<IBrush?> BackgroundProperty
Field Value
CaretBlinkIntervalProperty
public static readonly StyledProperty<TimeSpan> CaretBlinkIntervalProperty
Field Value
CaretBrushProperty
public static readonly StyledProperty<IBrush?> CaretBrushProperty
Field Value
CaretIndexProperty
public static readonly StyledProperty<int> CaretIndexProperty
Field Value
LetterSpacingProperty
Defines the LetterSpacing property.
public static readonly StyledProperty<double> LetterSpacingProperty
Field Value
LineHeightProperty
Defines the LineHeight property.
public static readonly StyledProperty<double> LineHeightProperty
Field Value
PasswordCharProperty
public static readonly StyledProperty<char> PasswordCharProperty
Field Value
PreeditTextCursorPositionProperty
Defines the PreeditText property.
public static readonly StyledProperty<int?> PreeditTextCursorPositionProperty
Field Value
PreeditTextProperty
Defines the PreeditText property.
public static readonly StyledProperty<string?> PreeditTextProperty
Field Value
RevealPasswordProperty
public static readonly StyledProperty<bool> RevealPasswordProperty
Field Value
SelectionBrushProperty
public static readonly StyledProperty<IBrush?> SelectionBrushProperty
Field Value
SelectionEndProperty
public static readonly StyledProperty<int> SelectionEndProperty
Field Value
SelectionForegroundBrushProperty
public static readonly StyledProperty<IBrush?> SelectionForegroundBrushProperty
Field Value
SelectionStartProperty
public static readonly StyledProperty<int> SelectionStartProperty
Field Value
ShowSelectionHighlightProperty
public static readonly StyledProperty<bool> ShowSelectionHighlightProperty
Field Value
TextAlignmentProperty
Defines the TextAlignment property.
public static readonly StyledProperty<TextAlignment> TextAlignmentProperty
Field Value
TextProperty
Defines the Text property.
public static readonly StyledProperty<string?> TextProperty
Field Value
TextWrappingProperty
Defines the TextWrapping property.
public static readonly StyledProperty<TextWrapping> TextWrappingProperty
Field Value
Properties
Background
Gets or sets a brush used to paint the control's background.
public IBrush? Background { get; set; }
Property Value
BypassFlowDirectionPolicies
Gets a value indicating whether control bypass FlowDirecton policies.
protected override bool BypassFlowDirectionPolicies { get; }
Property Value
Remarks
Related to FlowDirection system and returns false as default, so if FlowDirection is RTL then control will get a mirror presentation. For controls that want to avoid this behavior, override this property and return true.
CaretBlinkInterval
Gets or sets the caret blink rate
public TimeSpan CaretBlinkInterval { get; set; }
Property Value
CaretBrush
public IBrush? CaretBrush { get; set; }
Property Value
CaretIndex
public int CaretIndex { get; set; }
Property Value
FontFamily
Gets or sets the font family.
public FontFamily FontFamily { get; set; }
Property Value
FontFeatures
Gets or sets the font family.
public FontFeatureCollection? FontFeatures { 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
LetterSpacing
Gets or sets the letter spacing.
public double LetterSpacing { get; set; }
Property Value
LineHeight
Gets or sets the line height. By default, this is set to NaN, which determines the appropriate height automatically.
public double LineHeight { get; set; }
Property Value
PasswordChar
public char PasswordChar { get; set; }
Property Value
PreeditText
public string? PreeditText { get; set; }
Property Value
PreeditTextCursorPosition
public int? PreeditTextCursorPosition { get; set; }
Property Value
- int?
RevealPassword
public bool RevealPassword { get; set; }
Property Value
SelectionBrush
public IBrush? SelectionBrush { get; set; }
Property Value
SelectionEnd
public int SelectionEnd { get; set; }
Property Value
SelectionForegroundBrush
public IBrush? SelectionForegroundBrush { get; set; }
Property Value
SelectionStart
public int SelectionStart { get; set; }
Property Value
ShowSelectionHighlight
Gets or sets a value that determines whether the TextPresenter shows a selection highlight.
public bool ShowSelectionHighlight { get; set; }
Property Value
Text
Gets or sets the text.
[Content]
public string? Text { get; set; }
Property Value
TextAlignment
Gets or sets the text alignment.
public TextAlignment TextAlignment { get; set; }
Property Value
TextLayout
Gets the TextLayout used to render the text.
public TextLayout TextLayout { get; }
Property Value
TextWrapping
Gets or sets the control's text wrapping mode.
public TextWrapping TextWrapping { get; set; }
Property Value
Methods
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.
CreateTextLayout()
Creates the TextLayout used to render the text.
protected virtual TextLayout CreateTextLayout()
Returns
- TextLayout
A TextLayout object.
GetNextCharacterHit(LogicalDirection)
public CharacterHit GetNextCharacterHit(LogicalDirection direction = LogicalDirection.Forward)
Parameters
direction
LogicalDirection
Returns
HideCaret()
public void HideCaret()
InvalidateTextLayout()
protected virtual void InvalidateTextLayout()
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.
MoveCaretHorizontal(LogicalDirection)
public void MoveCaretHorizontal(LogicalDirection direction = LogicalDirection.Forward)
Parameters
direction
LogicalDirection
MoveCaretToPoint(Point)
public void MoveCaretToPoint(Point point)
Parameters
point
Point
MoveCaretToTextPosition(int, bool)
public void MoveCaretToTextPosition(int textPosition, bool trailingEdge = false)
Parameters
MoveCaretVertical(LogicalDirection)
public void MoveCaretVertical(LogicalDirection direction = LogicalDirection.Forward)
Parameters
direction
LogicalDirection
OnAttachedToVisualTree(VisualTreeAttachmentEventArgs)
Called when the control is added to a rooted visual tree.
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
Parameters
e
VisualTreeAttachmentEventArgsThe event args.
OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs)
Called when the control is removed from a rooted visual tree.
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
Parameters
e
VisualTreeAttachmentEventArgsThe 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.
ShowCaret()
public void ShowCaret()
Events
CaretBoundsChanged
public event EventHandler? CaretBoundsChanged