Export (0) Print
Expand All

AutomationElement::GetCurrentPattern Method

Retrieves the specified pattern object on this AutomationElement.

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

public:
Object^ GetCurrentPattern(
	AutomationPattern^ pattern
)

Parameters

pattern
Type: System.Windows.Automation::AutomationPattern

The identifier of the pattern to retrieve.

Return Value

Type: System::Object
The pattern object, if the specified pattern is currently supported by the AutomationElement.

ExceptionCondition
InvalidOperationException

The pattern is not supported by the element.

ElementNotAvailableException

The UI for the AutomationElement no longer exists.

GetCurrentPattern gets the specified pattern based on its availability at the time of the call.

For some forms of UI, this method will incur cross-process performance overhead. Applications can concentrate overhead by caching patterns and then retrieving them by using GetCachedPattern.

The following example shows how to use this method to retrieve a SelectionItemPattern, which is then used to select an item in a list box.

No code example is currently available or this language may not be supported.
NoteNote

For often-repeated tasks such as the one in the example, it would be more efficient to cache the pattern and use GetCachedPattern.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft