When I access my application and I enumerate the controls by walking the tree using the RawTreeWalker there is an element that is not being enumerated. It's a popup element that comes from another drop down element. It ends up not being a child of the drop down but rather a child of the form containing the drop down. My monitoring application is able to find the element via CUIAutomationClass.ElementFromPoint and it can also properly build its parent hierarchy using IUIAutomationElement.GetCurrentParent recursively.
However if I click the popup and display it's content then enumerate from the base form using the RawTreeWalker the element is not found. I'd love for someone to point me to what I'm doing wrong. Here is my tree walker code.
private static IEnumerable<IUIAutomationElement> GetChildren(Element element) { var automation = new CUIAutomation8Class(); var walker = automation.CreateTreeWalker(automation.RawViewCondition); var child = walker.GetFirstChildElement(element.NativeElement); while (child != null) { yield return child; child = walker.GetNextSiblingElement(child); } }