Class SelectableTextBlock
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
CopyingToClipboardEvent
public static readonly RoutedEvent<RoutedEventArgs> CopyingToClipboardEvent
Field Value
SelectedTextProperty
public static readonly DirectProperty<SelectableTextBlock, string> SelectedTextProperty
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
Properties
CanCopy
Property for determining if the Copy command can be executed.
public bool CanCopy { get; }
Property Value
SelectedText
Gets the content of the current selection.
public string SelectedText { get; }
Property Value
SelectionBrush
Gets or sets the brush that highlights selected text.
public IBrush? SelectionBrush { get; set; }
Property Value
SelectionEnd
Gets or sets a character index for the end of the current selection.
public int SelectionEnd { get; set; }
Property Value
SelectionForegroundBrush
Gets or sets a brush that is used for the foreground of selected text
public IBrush? SelectionForegroundBrush { get; set; }
Property Value
SelectionStart
Gets or sets a character index for the beginning of the current selection.
public int SelectionStart { get; set; }
Property Value
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
GotFocusEventArgsThe event args.
OnKeyDown(KeyEventArgs)
Called before the KeyDown event occurs.
protected override void OnKeyDown(KeyEventArgs e)
Parameters
e
KeyEventArgsThe event args.
OnLostFocus(RoutedEventArgs)
Called before the LostFocus event occurs.
protected override void OnLostFocus(RoutedEventArgs e)
Parameters
e
RoutedEventArgsThe event args.
OnPointerMoved(PointerEventArgs)
Called before the PointerMoved event occurs.
protected override void OnPointerMoved(PointerEventArgs e)
Parameters
e
PointerEventArgsThe event args.
OnPointerPressed(PointerPressedEventArgs)
Called before the PointerPressed event occurs.
protected override void OnPointerPressed(PointerPressedEventArgs e)
Parameters
e
PointerPressedEventArgsThe event args.
OnPointerReleased(PointerReleasedEventArgs)
Called before the PointerReleased event occurs.
protected override void OnPointerReleased(PointerReleasedEventArgs e)
Parameters
e
PointerReleasedEventArgsThe 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.
RenderTextLayout(DrawingContext, Point)
protected override void RenderTextLayout(DrawingContext context, Point origin)
Parameters
context
DrawingContextorigin
Point
SelectAll()
Select all text in the TextBox
public void SelectAll()
Events
CopyingToClipboard
public event EventHandler<RoutedEventArgs>? CopyingToClipboard