共用方式為


SelectionItemPattern.SelectionContainerProperty 欄位

定義

識別 SelectionContainer 屬性。

public: static initonly System::Windows::Automation::AutomationProperty ^ SelectionContainerProperty;
public static readonly System.Windows.Automation.AutomationProperty SelectionContainerProperty;
 staticval mutable SelectionContainerProperty : System.Windows.Automation.AutomationProperty
Public Shared ReadOnly SelectionContainerProperty As AutomationProperty 

欄位值

範例

下列範例示範如何擷取 AutomationElement 代表選取專案選取容器的 。

///--------------------------------------------------------------------
/// <summary>
/// Retrieves the selection items for a selection container.
/// </summary>
/// <param name="rootElement">
/// The automation element from which to start searching.
/// </param>
/// <param name="selectionContainer">
/// An automation element that supports SelectionPattern.
/// </param>
/// <returns>
/// A collection of automation elements satisfying 
/// the specified condition(s).
/// </returns>
///--------------------------------------------------------------------
private AutomationElementCollection FindElementBasedOnContainer(
    AutomationElement rootElement, AutomationElement selectionContainer)
{
    PropertyCondition containerCondition = 
        new PropertyCondition(
        SelectionItemPattern.SelectionContainerProperty, 
        selectionContainer);
    AutomationElementCollection selectionItems = 
        rootElement.FindAll(TreeScope.Descendants, containerCondition);
    return selectionItems;
}
'''--------------------------------------------------------------------
''' <summary>
''' Retrieves the selection items for a selection container.
''' </summary>
''' <param name="rootElement">
''' The automation element from which to start searching.
''' </param>
''' <param name="selectionContainer">
''' An automation element that supports SelectionPattern.
''' </param>
''' <returns>
''' A collection of automation elements satisfying 
''' the specified condition(s).
''' </returns>
'''--------------------------------------------------------------------
Private Function FindElementBasedOnContainer( _
ByVal rootElement As AutomationElement, _
ByVal selectionContainer As AutomationElement) As AutomationElementCollection
    Dim containerCondition As PropertyCondition = _
        New PropertyCondition( _
        SelectionItemPattern.SelectionContainerProperty, _
        selectionContainer)
    Dim selectionItems As AutomationElementCollection = _
        rootElement.FindAll(TreeScope.Descendants, containerCondition)
    Return selectionItems
End Function

備註

消費者介面自動化用戶端應用程式會使用此識別碼。 消費者介面自動化提供者應該使用 中的 SelectionItemPatternIdentifiers 對等欄位。

適用於