ITextProvider2 ITextProvider2 ITextProvider2 Interface


Extends the ITextProvider interface to enable Microsoft UI Automation providers to expose textual content that is the target of an annotation or selection. Implement this interface in order to support the capabilities that an automation client requests with a GetPattern call and PatternInterface.Text2.

public : interface ITextProvider2 : ITextProvider
public interface ITextProvider2 : ITextProvider
Public Interface ITextProvider2 Implements ITextProvider
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


For more info on this pattern, see Text and TextRange Control Patterns.

ITextProvider, ITextProvider2 and ITextRangeProvider aren't implemented by any existing Windows Runtime automation peers using this definition of the interface. The text models supported by Windows Runtime text controls such as TextBox and RichTextBlock do implement some of these patterns, but do so at a native level that doesn't appear in the Windows Runtime definitions of the API surface. For more info, see the peer classes for the various Windows Runtime text controls.

The ITextProvider2 pattern doesn't have a Windows Runtime property identifier class.

Interface inheritance

ITextProvider2 inherits ITextProvider. Types that implement ITextProvider2 also implement the interface members of ITextProvider.


GetCaretRange(Boolean) GetCaretRange(Boolean) GetCaretRange(Boolean)

Retrieves a zero-length text range at the location of the caret that belongs to the text-based control.

public : ITextRangeProvider GetCaretRange(bool isActive)
public ITextRangeProvider GetCaretRange(Boolean isActive)
Public Function GetCaretRange(isActive As Boolean) As ITextRangeProvider
bool Boolean Boolean

true if the text-based control that contains the caret has keyboard focus; otherwise, false.


A text range that represents the current location of the caret that belongs to the text-based control.

GetSelection GetSelection GetSelection

Retrieves a collection of disjoint text ranges that are associated with the current text selection or selections.

(Inherited from ITextProvider)

GetVisibleRanges GetVisibleRanges GetVisibleRanges

Retrieves an array of disjoint text ranges from a text container. Each text range begins with the first partially visible line and ends with the last partially visible line.

(Inherited from ITextProvider)

RangeFromAnnotation(IRawElementProviderSimple) RangeFromAnnotation(IRawElementProviderSimple) RangeFromAnnotation(IRawElementProviderSimple)

Exposes a text range that contains the text that is the target of the annotation associated with the specified annotation element.

public : ITextRangeProvider RangeFromAnnotation(IRawElementProviderSimple annotationElement)
public ITextRangeProvider RangeFromAnnotation(IRawElementProviderSimple annotationElement)
Public Function RangeFromAnnotation(annotationElement As IRawElementProviderSimple) As ITextRangeProvider
IRawElementProviderSimple IRawElementProviderSimple IRawElementProviderSimple

The provider for an element that implements the IAnnotationProvider interface. The annotation element is a sibling of the element that implements the ITextProvider2 interface for the document.


A text range that contains the annotation target text.

RangeFromChild(IRawElementProviderSimple) RangeFromChild(IRawElementProviderSimple) RangeFromChild(IRawElementProviderSimple)

Retrieves a text range that encloses a child element, such as an image, hyperlink, or other embedded object.

(Inherited from ITextProvider)

RangeFromPoint(Point) RangeFromPoint(Point) RangeFromPoint(Point)

Retrieves a text range from the vicinity of a screen coordinate.

(Inherited from ITextProvider)


DocumentRange DocumentRange DocumentRange

Gets a text range that encloses the main text of a document.

(Inherited from ITextProvider)

SupportedTextSelection SupportedTextSelection SupportedTextSelection

Gets a value that specifies whether a text provider supports selection, and if it does, the type of selection that is supported.

(Inherited from ITextProvider)

See Also