AutomationElement.RootElement Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the root AutomationElement for the current desktop.
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
Property Value
The root element.
Examples
The following example code retrieves a collection of all the immediate children of the desktop.
AutomationElementCollection desktopChildren =
AutomationElement.RootElement.FindAll(
TreeScope.Children, Condition.TrueCondition);
Dim desktopChildren As AutomationElementCollection
desktopChildren = AutomationElement.RootElement.FindAll( _
TreeScope.Children, Condition.TrueCondition)
Remarks
You can use the root element as a starting point for finding other elements, using the FindAll and FindFirst methods.
When searching from the root element, be sure to specify Children in the scope of the search, not Descendants. A search through the entire subtree of the desktop could iterate through thousands of items and lead to a stack overflow.
Applies to
.NET