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

控件模式的标识符。

返回

控件模式的友好名称;如果找不到指定的模式,则为空引用(在 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

适用于