SelectionPattern.Pattern 欄位

定義

識別 SelectionPattern 控制項模式。Identifies the SelectionPattern control pattern.

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

欄位值

AutomationPattern

範例

在下列範例中, SelectionPattern 會從取得控制項模式 AutomationElementIn the following example, a SelectionPattern control pattern is obtained from an AutomationElement.

///--------------------------------------------------------------------
/// <summary>
/// Obtains a SelectionPattern control pattern from an 
/// automation element.
/// </summary>
/// <param name="targetControl">
/// The automation element of interest.
/// </param>
/// <returns>
/// A SelectionPattern object.
/// </returns>
///--------------------------------------------------------------------
private SelectionPattern GetSelectionPattern(
    AutomationElement targetControl)
{
    SelectionPattern selectionPattern = null;

    try
    {
        selectionPattern =
            targetControl.GetCurrentPattern(SelectionPattern.Pattern)
            as SelectionPattern;
    }
    // Object doesn't support the SelectionPattern control pattern
    catch (InvalidOperationException)
    {
        return null;
    }

    return selectionPattern;
}
'''--------------------------------------------------------------------
''' <summary>
''' Obtains a SelectionPattern control pattern from an 
''' automation element.
''' </summary>
''' <param name="targetControl">
''' The automation element of interest.
''' </param>
''' <returns>
''' A SelectionPattern object.
''' </returns>
'''--------------------------------------------------------------------
Private Function GetSelectionPattern( _
ByVal targetControl As AutomationElement) As SelectionPattern
    Dim selectionPattern As SelectionPattern = Nothing

    Try
        selectionPattern = DirectCast( _
        targetControl.GetCurrentPattern(selectionPattern.Pattern), _
        SelectionPattern)
    ' Object doesn't support the SelectionPattern control pattern
    Catch
        Return Nothing
    End Try

    Return selectionPattern
End Function 'GetSelectionPattern

備註

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

模式識別碼會傳遞至方法(例如), GetCurrentPattern 以從指定的取得相關的控制項模式 AutomationElementThe pattern identifier is passed to methods such as GetCurrentPattern to retrieve the control pattern of interest from the specified AutomationElement.

適用於