Export (0) Print
Expand All

TogglePattern.TogglePatternInformation.ToggleState Property

Retrieves the toggle state of the AutomationElement.

Namespace: System.Windows.Automation
Assembly: UIAutomationClient (in uiautomationclient.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

'Declaration
Public ReadOnly Property ToggleState As ToggleState
'Usage
Dim instance As TogglePatternInformation
Dim value As ToggleState

value = instance.ToggleState

/** @property */
public ToggleState get_ToggleState ()

public function get ToggleState () : ToggleState

Not applicable.

Property Value

The ToggleState of the AutomationElement. The default value is Indeterminate.

An AutomationElement must cycle through its ToggleState in this order: On, Off and, if supported, 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 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    

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

ADD
Show:
© 2014 Microsoft