private IUIAutomationElement GetParent(IUIAutomationTreeWalker treeWalker, IUIAutomationElement element) { if (element == null) { return(null); } return(treeWalker?.GetParentElement(element)); }
public AutomationElement GetParent() { IUIAutomationTreeWalker walker = factory.CreateTreeWalker(); try { IUIAutomationElement elem; walker.GetParentElement(pElement, out elem); return((elem == null) ? null : new AutomationElement(elem, factory)); } finally { if (walker != null) { Marshal.ReleaseComObject(walker); } } }