AndCondition.GetConditions Method ()


Retrieves an array of the subconditions for this condition.

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

public Condition[] GetConditions()

The returned array is a copy. Modifying it does not affect the state of the AndCondition.

The following example constructs an AndCondition and then displays the number of conditions it contains.

/// <summary>
/// Uses AndCondition to retrieve elements that match both of two conditions.
/// </summary>
/// <param name="elementMainWindow">An application window element.</param>
public void AndConditionExample(AutomationElement elementMainWindow)
    if (elementMainWindow == null)
        throw new ArgumentException();

    AndCondition conditionEnabledButtons = new AndCondition(
        new PropertyCondition(AutomationElement.IsEnabledProperty, true),
        new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button));
    AutomationElementCollection enabledButtons = elementMainWindow.FindAll(
        TreeScope.Subtree, conditionEnabledButtons);
    Console.WriteLine("\nEnabled buttons:");
    foreach (AutomationElement autoElement in enabledButtons)

    // Example of getting the conditions from the AndCondition.
    Condition[] conditions = conditionEnabledButtons.GetConditions();
    Console.WriteLine("AndCondition has " + conditions.GetLength(0) + " subconditions.");


.NET Framework
Available since 3.0
Return to top