Table of Contents

Class SelectableTextBlock

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll

A control that displays a block of formatted text.

public class SelectableTextBlock : TextBlock, INotifyPropertyChanged, IDataContextProvider, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, ILogical
Inheritance
SelectableTextBlock
Implements
Inherited Members
Extension Methods

Constructors

SelectableTextBlock()

public SelectableTextBlock()

Fields

CanCopyProperty

public static readonly DirectProperty<SelectableTextBlock, bool> CanCopyProperty

Field Value

DirectProperty<SelectableTextBlock, bool>

CopyingToClipboardEvent

public static readonly RoutedEvent<RoutedEventArgs> CopyingToClipboardEvent

Field Value

RoutedEvent<RoutedEventArgs>

SelectedTextProperty

public static readonly DirectProperty<SelectableTextBlock, string> SelectedTextProperty

Field Value

DirectProperty<SelectableTextBlock, string>

SelectionBrushProperty

public static readonly StyledProperty<IBrush?> SelectionBrushProperty

Field Value

StyledProperty<IBrush>

SelectionEndProperty

public static readonly StyledProperty<int> SelectionEndProperty

Field Value

StyledProperty<int>

SelectionForegroundBrushProperty

public static readonly StyledProperty<IBrush?> SelectionForegroundBrushProperty

Field Value

StyledProperty<IBrush>

SelectionStartProperty

public static readonly StyledProperty<int> SelectionStartProperty

Field Value

StyledProperty<int>

Properties

CanCopy

Property for determining if the Copy command can be executed.

public bool CanCopy { get; }

Property Value

bool

SelectedText

Gets the content of the current selection.

public string SelectedText { get; }

Property Value

string

SelectionBrush

Gets or sets the brush that highlights selected text.

public IBrush? SelectionBrush { get; set; }

Property Value

IBrush

SelectionEnd

Gets or sets a character index for the end of the current selection.

public int SelectionEnd { get; set; }

Property Value

int

SelectionForegroundBrush

Gets or sets a brush that is used for the foreground of selected text

public IBrush? SelectionForegroundBrush { get; set; }

Property Value

IBrush

SelectionStart

Gets or sets a character index for the beginning of the current selection.

public int SelectionStart { get; set; }

Property Value

int

Methods

ClearSelection()

Clears the current selection

public void ClearSelection()

Copy()

Copies the current selection to the Clipboard.

public void Copy()

CreateTextLayout(string?)

Creates the TextLayout used to render the text.

protected override TextLayout CreateTextLayout(string? text)

Parameters

text string

Returns

TextLayout

A TextLayout object.

OnGotFocus(GotFocusEventArgs)

Called before the GotFocus event occurs.

protected override void OnGotFocus(GotFocusEventArgs e)

Parameters

e GotFocusEventArgs

The event args.

OnKeyDown(KeyEventArgs)

Called before the KeyDown event occurs.

protected override void OnKeyDown(KeyEventArgs e)

Parameters

e KeyEventArgs

The event args.

OnLostFocus(RoutedEventArgs)

Called before the LostFocus event occurs.

protected override void OnLostFocus(RoutedEventArgs e)

Parameters

e RoutedEventArgs

The event args.

OnPointerMoved(PointerEventArgs)

Called before the PointerMoved event occurs.

protected override void OnPointerMoved(PointerEventArgs e)

Parameters

e PointerEventArgs

The event args.

OnPointerPressed(PointerPressedEventArgs)

Called before the PointerPressed event occurs.

protected override void OnPointerPressed(PointerPressedEventArgs e)

Parameters

e PointerPressedEventArgs

The event args.

OnPointerReleased(PointerReleasedEventArgs)

Called before the PointerReleased event occurs.

protected override void OnPointerReleased(PointerReleasedEventArgs e)

Parameters

e PointerReleasedEventArgs

The event args.

OnPropertyChanged(AvaloniaPropertyChangedEventArgs)

Called when a avalonia property changes on the object.

protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)

Parameters

change AvaloniaPropertyChangedEventArgs

The property change details.

RenderTextLayout(DrawingContext, Point)

protected override void RenderTextLayout(DrawingContext context, Point origin)

Parameters

context DrawingContext
origin Point

SelectAll()

Select all text in the TextBox

public void SelectAll()

Events

CopyingToClipboard

public event EventHandler<RoutedEventArgs>? CopyingToClipboard

Event Type

EventHandler<RoutedEventArgs>