Class TextSelection
Manages the current text range selected in a Telerik.Windows.Documents.Fixed.Text.TextDocument, enabling querying, geometry extraction, and modification of the highlighted content.
Inheritance
Inherited Members
Namespace: Telerik.Windows.Documents.Fixed.Selection
Assembly: Telerik.Windows.Documents.Fixed.dll
Syntax
public class TextSelection
Properties
EndPosition
Gets the focus (later) text position of the current selection, or null when no selection exists.
Declaration
public TextPosition EndPosition { get; }
Property Value
|
TextPosition
The end position. |
IsEmpty
Gets a value indicating whether no text is currently selected (start and end are identical or both null).
Declaration
public bool IsEmpty { get; }
Property Value
|
System.Boolean
|
StartPosition
Gets the anchor (earlier) text position of the current selection, or null when no selection exists.
Declaration
public TextPosition StartPosition { get; }
Property Value
|
TextPosition
The start position. |
Methods
Clear()
Clears any current selection, leaving no selected text.
Declaration
public void Clear()
GetSelectedText()
Returns the text within the current selection range using document line separators, or an empty string if none is selected.
Declaration
public string GetSelectedText()
Returns
|
System.String
A string containing the text content within the current selection, or an empty string if no text is selected. |
GetSelectedTextAsync()
Asynchronously retrieves the currently selected text; returns an empty string if another retrieval is already running.
Declaration
public Task<string> GetSelectedTextAsync()
Returns
|
System.Threading.Tasks.Task<System.String>
A task that represents the asynchronous operation. The task result contains the text content within the current selection. |
GetSelectionGeometry(RadFixedPage)
Builds a path geometry outlining the selected text fragments that lie on the specified page for highlighting or custom adorners.
Declaration
public PathGeometry GetSelectionGeometry(RadFixedPage page)
Parameters
|
RadFixedPage
page
The page for which to retrieve the selection geometry. |
Returns
|
System.Windows.Media.PathGeometry
A PathGeometry object representing the visual bounds of the text selection on the specified page. |
Remarks
The geometry can be used for highlighting or other visual representations of the selected text.
SelectAll()
Selects the entire document content.
Declaration
public void SelectAll()
SetSelection(TextPosition, TextPosition)
Defines the selection range using the supplied start and end positions (both must belong to this document).
Declaration
public void SetSelection(TextPosition startPosition, TextPosition endPosition)
Parameters
|
TextPosition
startPosition
The start position. |
|
TextPosition
endPosition
The end position. |
SetSelectionEnd(TextPosition)
Sets or moves the end anchor of the selection while preserving the current start (or using it when none exists).
Declaration
public void SetSelectionEnd(TextPosition endPosition)
Parameters
|
TextPosition
endPosition
The end position. |
SetSelectionStart(TextPosition)
Sets or moves the start anchor of the selection while preserving the current end (or using it when none exists).
Declaration
public void SetSelectionStart(TextPosition startPosition)
Parameters
|
TextPosition
startPosition
The start position. |
ToString()
Returns the currently selected text.
Declaration
public override string ToString()
Returns
|
System.String
A string that represents the current object. |
Overrides
Events
SelectionChanged
Raised after the selection range has changed.
Declaration
public event EventHandler SelectionChanged
Event Type
|
System.EventHandler
|
SelectionChanging
Raised before the selection range changes so listeners can update related UI state.
Declaration
public event EventHandler SelectionChanging
Event Type
|
System.EventHandler
|