Export (0) Print
Expand All

AutomationElement.TryGetCurrentPattern Method

Retrieves an object that implements a control pattern.

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

public bool TryGetCurrentPattern (
	AutomationPattern pattern,
	out Object patternObject
)
public boolean TryGetCurrentPattern (
	AutomationPattern pattern, 
	/** @attribute OutAttribute() */ /** @ref */ Object patternObject
)
Not applicable.

Parameters

pattern

The identifier of the control pattern to retrieve.

patternObject

On return, the control pattern if it is supported; otherwise a null reference (Nothing in Visual Basic).

Return Value

true if the pattern is supported; otherwise false.

For some forms of user interface (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 control pattern.

// element is an AutomationElement.
object objPattern;
SelectionPattern selPattern;
if (true == element.TryGetCurrentPattern(SelectionPattern.Pattern, out objPattern))
{
    selPattern = objPattern as SelectionPattern;
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft