AutomationElement.Cached AutomationElement.Cached AutomationElement.Cached AutomationElement.Cached Property

정의

UI 자동화UI Automation 개체에 대해 캐시된 AutomationElement 속성 값을 가져옵니다.Gets the cached UI 자동화UI Automation property values for this AutomationElement object.

public:
 property System::Windows::Automation::AutomationElement::AutomationElementInformation Cached { System::Windows::Automation::AutomationElement::AutomationElementInformation get(); };
public System.Windows.Automation.AutomationElement.AutomationElementInformation Cached { get; }
member this.Cached : System.Windows.Automation.AutomationElement.AutomationElementInformation
Public ReadOnly Property Cached As AutomationElement.AutomationElementInformation

속성 값

예외

캐시된 속성이 없는 경우There are no cached properties.

예제

다음 예제와 방법을 Name 속성을 캐시 하 고 사용 하 여 검색 한 다음는 Cached 속성입니다.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>
void CachePropertiesWithScope(AutomationElement elementMain)
{
    AutomationElement elementList;

    // Set up the CacheRequest.
    CacheRequest cacheRequest = new CacheRequest();
    cacheRequest.Add(AutomationElement.NameProperty);
    cacheRequest.TreeScope = TreeScope.Element | 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.
        Condition cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.List);
        elementList = elementMain.FindFirst(TreeScope.Children, cond);
    }
    if (elementList == null) return;

    // The following illustrates that the children of the list are in the cache.
    foreach (AutomationElement listItem in elementList.CachedChildren)
    {
        Console.WriteLine(listItem.Cached.Name);
    }

    // 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.
    AutomationElement child = elementList.CachedChildren[0];
    Console.WriteLine(child.CachedParent.Cached.Name);
}
''' <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

설명

에 대 한 접근자 UI 자동화UI Automation 속성에서 반환 된 구조체의 속성으로 표현 됩니다 Cached합니다.The accessors for UI 자동화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. 사용 가능한 속성 및 해당 용도에 대 한 자세한 내용은 참조 하세요. AutomationElement.AutomationElementInformation합니다.For specific information on the properties available and their use, see AutomationElement.AutomationElementInformation.

현재 값을 가져올 UI 자동화UI Automation 요소 사용 하 여가 속성을 Current 속성입니다.To get the current value of UI 자동화UI Automation properties on this element use the Current property.

적용 대상

추가 정보