TogglePattern.Pattern Field  
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Identifies the TogglePattern control pattern.
public: static initonly System::Windows::Automation::AutomationPattern ^ Pattern;public static readonly System.Windows.Automation.AutomationPattern Pattern; staticval mutable Pattern : System.Windows.Automation.AutomationPatternPublic Shared ReadOnly Pattern As AutomationPattern Field Value
Examples
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;
    try
    {
        togglePattern =
            targetControl.GetCurrentPattern(TogglePattern.Pattern)
            as TogglePattern;
    }
    catch (InvalidOperationException)
    {
        // object doesn't support the TogglePattern control pattern
        return null;
    }
    return togglePattern;
}
'''--------------------------------------------------------------------
''' <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 Function GetTogglePattern( _
ByVal targetControl As AutomationElement) As TogglePattern
    Dim togglePattern As TogglePattern = Nothing
    Try
        togglePattern = DirectCast( _
        targetControl.GetCurrentPattern(togglePattern.Pattern), _
        TogglePattern)
    Catch
        ' object doesn't support the TogglePattern control pattern
        Return Nothing
    End Try
    Return togglePattern
End Function 'GetTogglePattern
Remarks
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.