Share via


TogglePattern.Pattern Campo

Definizione

Identifica il pattern di controllo TogglePattern.

public: static initonly System::Windows::Automation::AutomationPattern ^ Pattern;
public static readonly System.Windows.Automation.AutomationPattern Pattern;
 staticval mutable Pattern : System.Windows.Automation.AutomationPattern
Public Shared ReadOnly Pattern As AutomationPattern 

Valore del campo

Esempio

Nell'esempio seguente viene ottenuto un TogglePattern pattern di controllo da un oggetto 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

Commenti

Questo identificatore viene usato da Automazione interfaccia utente applicazioni client. Automazione interfaccia utente provider devono usare il campo equivalente in TogglePatternIdentifiers.

L'identificatore del modello viene passato a metodi quali GetCurrentPattern per recuperare il pattern di controllo di interesse dall'oggetto specificato AutomationElement.

Si applica a