Pattern Field
Collapse the table of content
Expand the table of content

InvokePattern.Pattern Field

 

Identifies the InvokePatterncontrol pattern.

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

public static readonly AutomationPattern Pattern

This identifier is used by UI Automation client applications. UI Automation providers should use the equivalent field in InvokePatternIdentifiers.

The pattern identifier is passed to methods such as GetCurrentPattern to retrieve the control pattern of interest from the specified AutomationElement.

In the following example an InvokePatterncontrol pattern is obtained from a control and the Invoke method is called.

///--------------------------------------------------------------------
/// <summary>
/// Obtains an InvokePattern control pattern from a control
/// and calls the InvokePattern.Invoke() method on the control.
/// </summary>
/// <param name="targetControl">
/// The control of interest.
/// </param>
///--------------------------------------------------------------------
private void InvokeControl(AutomationElement targetControl)
{
    InvokePattern invokePattern = null;

    try
    {
        invokePattern =
            targetControl.GetCurrentPattern(InvokePattern.Pattern)
            as InvokePattern;
    }
    catch (ElementNotEnabledException)
    {
        // Object is not enabled
        return;
    }
    catch (InvalidOperationException)
    {
        // object doesn't support the InvokePattern control pattern
        return;
    }

    invokePattern.Invoke();
}

.NET Framework
Available since 3.0
Return to top
Show:
© 2016 Microsoft