AutomationElement.Cached Property
Assembly: UIAutomationClient (in uiautomationclient.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
'Declaration Public ReadOnly Property Cached As AutomationElementInformation 'Usage Dim instance As AutomationElement Dim value As AutomationElementInformation value = instance.Cached
/** @property */ public AutomationElementInformation get_Cached ()
public function get Cached () : AutomationElementInformation
Not applicable.
Property Value
A structure containing the cached property values for the AutomationElement.The accessors for UI Automation properties are represented as properties of the structure returned by Cached. You do not need to retrieve the structure; you can access its members directly, as in the example below. For specific information on the properties available and their use, see AutomationElement.AutomationElementInformation.
To get the current value of UI Automation properties on this element use the Current property.
The following example shows how the Name property can be cached and then retrieved by using the Cached property.
''' <summary> ''' Gets a list box element and caches the Name property of its children (the list items). ''' </summary> ''' <param name="elementMain">The UI Automation element for the parent window.</param> Sub CachePropertiesWithScope(ByVal elementMain As AutomationElement) Dim elementList As AutomationElement ' Set up the CacheRequest. Dim cacheRequest As New CacheRequest() cacheRequest.Add(AutomationElement.NameProperty) cacheRequest.TreeScope = TreeScope.Element Or TreeScope.Children ' Activate the CacheRequest and get the element. Note that the scope of the CacheRequest ' is in relation to the object being retrieved: the list box and its children are ' cached, not the main window and its children. Using cacheRequest.Activate() ' Load the list element and cache the specified properties for its descendants. Dim myCondition As New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.List) elementList = elementMain.FindFirst(TreeScope.Children, myCondition) If elementList Is Nothing Then Return End If ' The following illustrates that the children of the list are in the cache. Dim listItem As AutomationElement For Each listItem In elementList.CachedChildren Console.WriteLine(listItem.Cached.Name) Next listItem ' The following call raises an exception, because the IsEnabled property was not cached. '** Console.WriteLine(listItem.Cached.IsEnabled) ** ' The following illustrates that because the list box itself was cached, it is now ' available as the CachedParent of each list item. Dim child As AutomationElement = elementList.CachedChildren(0) Console.WriteLine(child.CachedParent.Cached.Name) End Using End Sub 'CachePropertiesWithScope
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.