TogglePattern.Pattern Field


Identifies the TogglePattern control 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 TogglePatternIdentifiers.

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, a TogglePattern control pattern is obtained from an AutomationElement.

/// <summary>
/// Obtains a TogglePattern control pattern from an automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A TogglePattern object.
/// </returns>
private TogglePattern GetTogglePattern(AutomationElement targetControl)
    TogglePattern togglePattern = null;

        togglePattern =
            as TogglePattern;
    catch (InvalidOperationException)
        // object doesn't support the TogglePattern control pattern
        return null;

    return togglePattern;

.NET Framework
Available since 3.0
Return to top