Class TextSelection
Encapsulates the selection state for the RichTextBox control.
Inheritance
Inherited Members
Namespace: System.Windows.Documents
Assembly: OpenSilver.dll
Syntax
public sealed class TextSelection
Properties
| Improve this Doc View SourceEnd
Gets a TextPointer that represents the end of the current selection.
Declaration
public TextPointer End { get; }
Property Value
Type | Description |
---|---|
TextPointer | A TextPointer that represents the end of the current selection. |
Start
Gets a TextPointer that represents the beginning of the current selection.
Declaration
public TextPointer Start { get; }
Property Value
Type | Description |
---|---|
TextPointer | A TextPointer that represents the beginning of the current selection. |
Text
Gets or sets the plain text contents of the current selection.
Declaration
public string Text { get; set; }
Property Value
Type | Description |
---|---|
System.String | A string that contains the plain text contents of the current selection. |
Xaml
Gets or sets the XAML representation of the current selection.
Declaration
public string Xaml { get; set; }
Property Value
Type | Description |
---|---|
System.String | A System.String that is a XAML representation of the current selection. This XAML representation is the same XAML that is applied to the clipboard for a copy operation. |
Methods
| Improve this Doc View SourceApplyPropertyValue(DependencyProperty, Object)
Applies the specified formatting property and value to the current selection.
Declaration
public void ApplyPropertyValue(DependencyProperty formattingProperty, object value)
Parameters
Type | Name | Description |
---|---|---|
DependencyProperty | formattingProperty | A formatting property to apply. |
System.Object | value | The value for the formatting property. |
GetPropertyValue(DependencyProperty)
Gets the value of the specified formatting property on the current selection.
Declaration
public object GetPropertyValue(DependencyProperty formattingProperty)
Parameters
Type | Name | Description |
---|---|---|
DependencyProperty | formattingProperty | A formatting property to get the value of on the current selection. |
Returns
Type | Description |
---|---|
System.Object | An object that indicates the value of the specified formatting property on the current selection. |
Insert(TextElement)
Inserts or replaces the content at the current selection as a TextElement.
Declaration
public void Insert(TextElement element)
Parameters
Type | Name | Description |
---|---|---|
TextElement | element | The TextElement to be inserted. |
Select(TextPointer, TextPointer)
Updates the current selection, taking two TextPointer positions to indicate the updated selection.
Declaration
public void Select(TextPointer anchorPosition, TextPointer movingPosition)
Parameters
Type | Name | Description |
---|---|---|
TextPointer | anchorPosition | A fixed anchor position that marks one end of the updated selection. |
TextPointer | movingPosition | A movable position that marks the other end of the updated selection. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | anchorPosition or movingPosition is null. |
System.ArgumentException | Position specifies a position from a different RichTextBox associated with the current position. |