OrCondition.GetConditions 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
检索在此条件中进行组合的各个条件。
public:
cli::array <System::Windows::Automation::Condition ^> ^ GetConditions();
public System.Windows.Automation.Condition[] GetConditions ();
member this.GetConditions : unit -> System.Windows.Automation.Condition[]
Public Function GetConditions () As Condition()
返回
组合成此条件的各个条件。
示例
下面的示例函数构造 , OrCondition 然后显示它包含的子条件数。
/// <summary>
/// Uses OrCondition to retrieve elements that match either of two conditions.
/// </summary>
/// <param name="elementMainWindow">An application window element.</param>
public void OrConditionExample(AutomationElement elementMainWindow)
{
if (elementMainWindow == null)
{
throw new ArgumentException();
}
OrCondition conditionButtons = new OrCondition(
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button),
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.RadioButton));
AutomationElementCollection elementCollectionButtons = elementMainWindow.FindAll(
TreeScope.Subtree, conditionButtons);
Console.WriteLine("\nButtons and radio buttons:");
foreach (AutomationElement autoElement in elementCollectionButtons)
{
Console.WriteLine(autoElement.Current.Name);
}
// Example of getting the conditions from the OrCondition.
Condition[] conditions = conditionButtons.GetConditions();
Console.WriteLine("OrCondition has " + conditions.GetLength(0) + " subconditions.");
}
''' <summary>
''' Uses OrCondition to retrieve elements that match either of two conditions.
''' </summary>
''' <param name="elementMainWindow">An application window element.</param>
Public Sub OrConditionExample(ByVal elementMainWindow As AutomationElement)
If elementMainWindow Is Nothing Then
Throw New ArgumentException()
End If
Dim conditionButtons As New OrCondition(New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Button), New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.RadioButton))
Dim elementCollectionButtons As AutomationElementCollection = elementMainWindow.FindAll(TreeScope.Subtree, conditionButtons)
Console.WriteLine("Buttons and radio buttons:")
Dim autoElement As AutomationElement
For Each autoElement In elementCollectionButtons
Console.WriteLine(autoElement.Current.Name)
Next autoElement
' Example of getting the conditions from the OrCondition.
Dim conditions As Condition() = conditionButtons.GetConditions()
Console.WriteLine("OrCondition has " & conditions.GetLength(0) & " subconditions.")
End Sub
注解
返回的数组是一个副本。 对其进行修改不会影响条件的状态。