AutomationElement.GetCurrentPattern Method (AutomationPattern)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Retrieves the specified pattern object on this AutomationElement.

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

member GetCurrentPattern : 
        pattern:AutomationPattern -> Object

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.

Exception Condition
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.
System_CAPS_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
Available since 3.0
Return to top
Show: