Skip to content

Latest commit

 

History

History
33 lines (25 loc) · 2.7 KB

obtain-mixed-text-attribute-details-using-ui-automation.md

File metadata and controls

33 lines (25 loc) · 2.7 KB
title description ms.date dev_langs ms.topic
Obtain Mixed Text Attribute Details Using UI Automation
Obtain mixed text attribute details using the managed UI Automation classes in the System.Windows.Automation namespace of the .NET API.
03/30/2017
csharp
vb
how-to

Obtain Mixed Text Attribute Details Using UI Automation

Note

This documentation is intended for .NET Framework developers who want to use the managed UI Automation classes defined in the xref:System.Windows.Automation namespace. For the latest information about UI Automation, see Windows Automation API: UI Automation.

This topic shows how to use Microsoft UI Automation to obtain text attribute details from a text range that spans multiple attribute values. A text range can correspond to the current location of the caret (or degenerate selection) within a document, a contiguous selection of text, a collection of disjoint text selections, or the entire textual content of a document.

Example

The following code example demonstrates how to obtain the xref:System.Windows.Automation.TextPattern.FontNameAttribute from a text range where xref:System.Windows.Automation.Text.TextPatternRange.GetAttributeValue%2A returns a xref:System.Windows.Automation.TextPattern.MixedAttributeValue object.

[!code-csharpFindText#RetrieveMixedAttributes] [!code-vbFindText#RetrieveMixedAttributes]

The xref:System.Windows.Automation.TextPattern control pattern, in tandem with the xref:System.Windows.Automation.Text.TextPatternRange class, supports basic text attributes, properties, and methods. For control-specific functionality that is not supported by xref:System.Windows.Automation.TextPattern or xref:System.Windows.Automation.Text.TextPatternRange, the xref:System.Windows.Automation.AutomationElement class provides methods for a UI Automation client to access the corresponding native object model.

See also