ITextRangeProvider.MoveEndpointByUnit Method
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Moves one endpoint of the text range the specified number of text units within the document range.
Assembly: System.Windows (in System.Windows.dll)
Parameters
- endpoint
- Type: System.Windows.Automation.Text.TextPatternRangeEndpoint
The endpoint to move.
- unit
- Type: System.Windows.Automation.Text.TextUnit
The textual unit for moving.
- count
- Type: System.Int32
The number of units to move.
A positive value moves the endpoint forward; a negative value moves the endpoint backward; and a value of 0 has no effect.
Return Value
Type: System.Int32The number of units actually moved. This value can be less than the count requested if moving the endpoint extends beyond the start or end of the document.
To traverse the content of a text range, the following steps are performed by the API behavior in order for the Move method to execute successfully:
The text range is normalized; that is, the text range is collapsed to a degenerate range at the Start endpoint, which makes the End endpoint unnecessary. This step is performed to remove ambiguity where a text range spans unit boundaries; for example, "{The U}RL http://www.microsoft.com is embedded in text" where "{" and "}" are the text range endpoints.
The resulting range is moved backward in the DocumentRange to the beginning of the requested unit boundary.
The range is then expanded from a degenerate range state by moving the End endpoint by one requested unit boundary.
If the given TextUnit is not supported by the control, MoveEndpointByUnit defers to the next largest supported TextUnit.
The order, from the smallest text unit to the largest, is as follows: