共用方式為


SelectionItemPattern.Pattern 欄位

定義

識別 SelectionItemPattern 控制項模式。

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

範例

在下列範例中, SelectionItemPattern 會從 AutomationElement 取得控制項模式。

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

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

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

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

    Return selectionItemPattern
End Function 'GetSelectionItemPattern

備註

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

模式識別碼會傳遞至方法,例如從 GetCurrentPattern 指定的 AutomationElement 擷取感興趣的控制項模式。

適用於