AndCondition(Condition[]) Constructor
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.
Creates a PropertyCondition that is true if all the subconditions are true.
public:
AndCondition(... cli::array <System::Windows::Automation::Condition ^> ^ conditions);
public AndCondition (params System.Windows.Automation.Condition[] conditions);
new System.Windows.Automation.AndCondition : System.Windows.Automation.Condition[] -> System.Windows.Automation.AndCondition
Public Sub New (ParamArray conditions As Condition())
Parameters
- conditions
- Condition[]
Two or more subconditions.
Examples
The following example shows how to use AndCondition to find UI Automation elements that match a complex condition.
/// <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)
{
Console.WriteLine(autoElement.Current.Name);
}
// Example of getting the conditions from the AndCondition.
Condition[] conditions = conditionEnabledButtons.GetConditions();
Console.WriteLine("AndCondition has " + conditions.GetLength(0) + " subconditions.");
}
''' <summary>
''' Uses AndCondition to retrieve elements that match both of two conditions.
''' </summary>
''' <param name="elementMainWindow">An application window element.</param>
Public Sub AndConditionExample(ByVal elementMainWindow As AutomationElement)
If elementMainWindow Is Nothing Then
Throw New ArgumentException()
End If
Dim conditionEnabledButtons As New AndCondition(New PropertyCondition(AutomationElement.IsEnabledProperty, True), New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button))
Dim enabledButtons As AutomationElementCollection = elementMainWindow.FindAll(TreeScope.Subtree, conditionEnabledButtons)
Console.WriteLine("Enabled buttons:")
Dim autoElement As AutomationElement
For Each autoElement In enabledButtons
Console.WriteLine(autoElement.Current.Name)
Next autoElement
' Example of getting the conditions from the AndCondition.
Dim conditions As Condition() = conditionEnabledButtons.GetConditions()
Console.WriteLine("AndCondition has " & conditions.GetLength(0) & " subconditions.")
End Sub
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET