TextBlock.GetPositionFromPoint(Point, Boolean) Method

Definition

Returns a TextPointer to the position closest to a specified Point.

C#
public System.Windows.Documents.TextPointer GetPositionFromPoint(System.Windows.Point point, bool snapToText);

Parameters

point
Point

A Point in the coordinate space of the TextBlock for which to return a TextPointer.

snapToText
Boolean

true to return a TextPointer to the insertion point closest to point, whether or not point is inside a character's bounding box; false to return null if point is not inside a character's bounding box.

Returns

A TextPointer to the specified point, or null if snapToText is false and the specified point does not fall within a character bounding box in the TextBlock content area.

Exceptions

Current, valid layout information for the control is unavailable.

Remarks

This method always returns a valid TextPointer when snapToText is true.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10