ITextRangeProvider.MoveEndpointByUnit Method

Moves one endpoint of the text range the specified number of text units within the document range.

Namespace:  System.Windows.Automation.Provider
Assembly:  System.Windows (in System.Windows.dll)

int MoveEndpointByUnit(
	TextPatternRangeEndpoint endpoint,
	TextUnit unit,
	int count


Type: System.Windows.Automation.Text.TextPatternRangeEndpoint
The endpoint to move.
Type: System.Windows.Automation.Text.TextUnit
The textual unit for moving.
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.Int32
The 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:

  1. 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 is embedded in text" where "{" and "}" are the text range endpoints.

  2. The resulting range is moved backward in the DocumentRange to the beginning of the requested unit boundary.

  3. 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:


Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions