NotCondition.NotCondition Constructor

Initializes a new instance of the NotCondition class.

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

public NotCondition (
	Condition condition
public NotCondition (
	Condition condition
public function NotCondition (
	condition : Condition
Not applicable.



The condition to negate.

In the following example, a NotCondition is used to retrieve all elements that were not retrieved using another Condition.

/// <summary>
/// Uses NotCondition to retrieve elements that do not match specified conditions.
/// </summary>
/// <param name="elementMainWindow">An application window element.</param>
public void NotConditionExample(AutomationElement elementMainWindow)
    if (elementMainWindow == null)
        throw new ArgumentException();

    // Set up a condition that finds all buttons and radio buttons.
    OrCondition conditionButtons = new OrCondition(
        new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button),
        new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.RadioButton));

    // Use NotCondition to retrieve elements that are not buttons or radio buttons.
    Condition conditionNotButtons = new NotCondition(conditionButtons);
    AutomationElementCollection elementCollectionNotButtons = elementMainWindow.FindAll(
        TreeScope.Subtree, conditionNotButtons);
    Console.WriteLine("Elements other than buttons:");
    foreach (AutomationElement autoElement in elementCollectionNotButtons)

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions