TogglePattern.TogglePatternInformation.ToggleState プロパティ
定義
AutomationElement の切り替え状態を取得します。Retrieves the toggle state of the AutomationElement.
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
プロパティ値
AutomationElement の ToggleState。The ToggleState of the AutomationElement. 既定値は Indeterminate です。The default value is Indeterminate.
例
次の例では、ルート要素が、ルートの子孫であるオートメーション要素のコレクションを返す関数に渡され、一連のプロパティ条件を満たしています。In the following example, a root element is passed to a function that returns a collection of automation elements that are descendants of the root and satisfy a set of property conditions.
///--------------------------------------------------------------------
/// <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
注釈
は AutomationElement ToggleState On 、、、 Off および (サポートされている場合) の順序でを順番に実行する必要があります Indeterminate 。An AutomationElement must cycle through its ToggleState in this order: On, Off and, if supported, Indeterminate.