共用方式為


Automation.PatternName(AutomationPattern) 方法

定義

擷取指定之控制項模式的名稱。

public:
 static System::String ^ PatternName(System::Windows::Automation::AutomationPattern ^ pattern);
public static string PatternName (System.Windows.Automation.AutomationPattern pattern);
static member PatternName : System.Windows.Automation.AutomationPattern -> string
Public Shared Function PatternName (pattern As AutomationPattern) As String

參數

pattern
AutomationPattern

控制項模式的識別項。

傳回

控制項模式的易記名稱,如果找不到指定的模式,則為 Null 參考 (在 Visual Basic 中為 Nothing)。

範例

下列範例會顯示 所支援 AutomationElement 之每個控制項模式的名稱。

注意

呼叫 GetSupportedPatterns 需要大量處理,因為它會查詢 AutomationElement 每個可能模式的 。

// element is an AutomationElement.
AutomationPattern[] patterns = element.GetSupportedPatterns();
foreach (AutomationPattern pattern in patterns)
{
    Console.WriteLine("ProgrammaticName: " + pattern.ProgrammaticName);
    Console.WriteLine("PatternName: " + Automation.PatternName(pattern));
}
' element is an AutomationElement.
Dim patterns As AutomationPattern() = element.GetSupportedPatterns()
Dim pattern As AutomationPattern
For Each pattern In patterns
    Console.WriteLine("ProgrammaticName: " + pattern.ProgrammaticName)
    Console.WriteLine("PatternName: " + Automation.PatternName(pattern))
Next pattern

適用於