Show / Hide Table of Contents

Class TextSelection

Encapsulates the selection state for the RichTextBox control.

Inheritance
System.Object
TextSelection
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: System.Windows.Documents
Assembly: OpenSilver.dll
Syntax
public sealed class TextSelection

Properties

| Improve this Doc View Source

End

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

ApplyPropertyValue(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

  • Improve this Doc
  • View Source