AutomationElement.GetSupportedPatterns 方法


擷取此 AutomationElement 支援的控制項模式。Retrieves the control patterns that this AutomationElement supports.

 cli::array <System::Windows::Automation::AutomationPattern ^> ^ GetSupportedPatterns();
public System.Windows.Automation.AutomationPattern[] GetSupportedPatterns ();
member this.GetSupportedPatterns : unit -> System.Windows.Automation.AutomationPattern[]
Public Function GetSupportedPatterns () As AutomationPattern()


AutomationPattern 物件陣列,代表支援的控制項模式。An array of AutomationPattern objects that represent the supported control patterns.


下列範例顯示如何抓取所支援AutomationElement的控制項模式。The following example shows how to retrieve the control patterns supported by an 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


這個方法通常會用來進行偵錯工具。This method would typically be used for debugging. 呼叫它需要大量的處理,因為它會查詢AutomationElement每個可能的模式。Calling it requires a great deal of processing, as it queries the AutomationElement for every possible pattern. 一般來說,您會GetCurrentPattern使用AutomationElement從取得特定的控制項模式。Normally you would use GetCurrentPattern to retrieve a specific control pattern from an AutomationElement. 若要確定是否支援特定模式,請檢查適當的屬性。例如, IsWindowPatternAvailablePropertyTo ascertain whether a particular pattern is supported, check the appropriate property; for example, IsWindowPatternAvailableProperty.