共用方式為


SelectionPattern.SelectionProperty 欄位

定義

識別可從容器中取得所選項目的屬性。

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 

欄位值

範例

在下列範例中,會取得 代表選取容器中選取專案的 集合 AutomationElement

///--------------------------------------------------------------------
/// <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

備註

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

此屬性不存在於 中 SelectionPattern.SelectionPatternInformation ,而且必須使用 或 GetCachedPropertyValue 來擷取 GetCurrentPropertyValue

適用於