SelectionPattern.SelectionProperty 欄位

定義

識別可從容器中取得所選項目的屬性。Identifies the property that gets the selected items in a container.

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

欄位值

AutomationProperty

範例

在下列範例中, AutomationElement 會取得代表選取容器中所選取專案的集合。In the following example, a collection of AutomationElements representing the selected items in a selection container is obtained.

///--------------------------------------------------------------------
/// <summary>
/// Gets the currently selected SelectionItem objects from target.
/// </summary>
/// <param name="selectionContainer">
/// The current Selection container object.
/// </param>
///--------------------------------------------------------------------
private AutomationElement[] GetCurrentSelectionProperty(
    AutomationElement selectionContainer)
{
    try
    {
        return selectionContainer.GetCurrentPropertyValue(
            SelectionPattern.SelectionProperty) as AutomationElement[];
    }
    // Container is not enabled
    catch (InvalidOperationException)
    {
        return null;
    }
}
'''--------------------------------------------------------------------
''' <summary>
''' Gets the currently selected SelectionItem objects from target.
''' </summary>
''' <param name="selectionContainer">
''' The current Selection container object.
''' </param>
'''--------------------------------------------------------------------
Private Function GetCurrentSelectionProperty( _
ByVal selectionContainer As AutomationElement) As AutomationElement()
    Try
        Return DirectCast(selectionContainer.GetCurrentPropertyValue( _
        SelectionPattern.SelectionProperty), AutomationElement())
        ' Container is not enabled
    Catch
        Return Nothing
    End Try
End Function 'GetCurrentSelectionProperty

備註

消費者介面自動化用戶端應用程式會使用此識別碼。This identifier is used by UI Automation client applications. 消費者介面自動化提供者應該使用中的對等欄位 SelectionPatternIdentifiersUI Automation providers should use the equivalent field in SelectionPatternIdentifiers.

這個屬性不存在於中 SelectionPattern.SelectionPatternInformation ,而且必須使用或進行 GetCurrentPropertyValue 取出 GetCachedPropertyValueThis property is not present in SelectionPattern.SelectionPatternInformation and must be retrieved by using GetCurrentPropertyValue or GetCachedPropertyValue.

適用於