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.


下列範例示範如何取出所支援的控制項模式 AutomationElementThe 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 從取出特定的控制項模式 AutomationElementNormally 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.