TogglePattern.TogglePatternInformation.ToggleState Özellik

Tanım

öğesinin geçiş durumunu AutomationElementalır.

public:
 property System::Windows::Automation::ToggleState ToggleState { System::Windows::Automation::ToggleState get(); };
public System.Windows.Automation.ToggleState ToggleState { get; }
member this.ToggleState : System.Windows.Automation.ToggleState
Public ReadOnly Property ToggleState As ToggleState

Özellik Değeri

öğesinin ToggleState .AutomationElement Indeterminate varsayılan değerdir.

Örnekler

Aşağıdaki örnekte kök öğesi, kökün alt öğeleri olan ve bir dizi özellik koşulunu karşılayan otomasyon öğeleri koleksiyonunu döndüren bir işleve geçirilir.

///--------------------------------------------------------------------
/// <summary>
/// Finds all automation elements that satisfy 
/// the specified condition(s).
/// </summary>
/// <param name="rootElement">
/// The automation element from which to start searching.
/// </param>
/// <returns>
/// A collection of automation elements satisfying 
/// the specified condition(s).
/// </returns>
///--------------------------------------------------------------------
private AutomationElementCollection FindAutomationElement(
    AutomationElement rootElement)
{
    if (rootElement == null)
    {
        throw new ArgumentException("Root element cannot be null.");
    }

    PropertyCondition conditionOn =
        new PropertyCondition(
        TogglePattern.ToggleStateProperty, ToggleState.On);

    PropertyCondition conditionIndeterminate =
        new PropertyCondition(
        TogglePattern.ToggleStateProperty, ToggleState.Indeterminate);

    // Use any combination of the preceding condtions to 
    // find the control(s) of interest
    OrCondition condition = new OrCondition(
        conditionOn,
        conditionIndeterminate);

    return rootElement.FindAll(TreeScope.Descendants, condition);
}
'''--------------------------------------------------------------------
''' <summary>
''' Finds all automation elements that satisfy 
''' the specified condition(s).
''' </summary>
''' <param name="rootElement">
''' The automation element from which to start searching.
''' </param>
''' <returns>
''' A collection of automation elements satisfying 
''' the specified condition(s).
''' </returns>
'''--------------------------------------------------------------------
Private Function FindAutomationElement( _
ByVal rootElement As AutomationElement) As AutomationElementCollection
    If rootElement Is Nothing Then
        Throw New ArgumentException("Root element cannot be null.")
    End If

    Dim conditionOn As New PropertyCondition( _
    TogglePattern.ToggleStateProperty, ToggleState.On)

    Dim conditionIndeterminate As New PropertyCondition( _
    TogglePattern.ToggleStateProperty, ToggleState.Indeterminate)

    ' Use any combination of the preceding condtions to 
    ' find the control(s) of interest
    Dim condition As OrCondition = _
    New OrCondition(conditionOn, conditionIndeterminate)

    Return rootElement.FindAll(TreeScope.Descendants, condition)

End Function 'FindAutomationElement

Açıklamalar

bir AutomationElement öğesinin şu sırayla geçiş ToggleState yapması gerekir: On, Off ve destekleniyorsa . Indeterminate

Şunlara uygulanır