語言

AutomationElement.RootElement 屬性

定義

取得目前桌面的根權限 AutomationElement 。

public:
 static property System::Windows::Automation::AutomationElement ^ RootElement { System::Windows::Automation::AutomationElement ^ get(); };
public static System.Windows.Automation.AutomationElement RootElement { get; }
static member RootElement : System.Windows.Automation.AutomationElement
Public Shared ReadOnly Property RootElement As AutomationElement

屬性值

根元素。

範例

以下範例程式碼會擷取桌面所有直接子節點的集合。

AutomationElementCollection desktopChildren =
    AutomationElement.RootElement.FindAll(
    TreeScope.Children, Condition.TrueCondition);
Dim desktopChildren As AutomationElementCollection
desktopChildren = AutomationElement.RootElement.FindAll( _
    TreeScope.Children, Condition.TrueCondition)

備註

你可以用根元素作為起點,使用 FindAll 和 FindFirst 方法尋找其他元素。

從根元素搜尋時,務必在搜尋範圍中指定 Children ,而非 Descendants。 搜尋桌面整個子樹可能會遍歷數千個項目,導致堆疊溢位。

適用於