TogglePattern.TogglePatternInformation.ToggleState 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
擷取 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
屬性值
ToggleState 的 AutomationElement。 預設值是 Indeterminate。
範例
在下列範例中,根項目會傳遞至函式,此函式會傳回屬於根子系的自動化專案集合,並滿足一組屬性條件。
///--------------------------------------------------------------------
/// <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 則為 。