TextBox.SelectionLength Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets or sets the number of characters in the current selection in the text box.
Assembly: System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.
<TextBox SelectionLength="int"/>
Property Value
Type: System.Int32The number of characters in the current selection in the text box, or 0 if there is no selection.
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | The value is less than 0. |
Getting this property returns the number of characters in the current selection. Setting this property adjusts the length of the current selection to the specified value, keeping the beginning of the selection fixed.
If the specified selection length is longer than the amount of text, the selection length automatically adjusts so that the resulting selection is never more than the amount of text.
A SelectionChanged event is raised when a valid SelectionLength is set.