how to get Parent UIItem

Dec 10, 2009 at 1:32 PM



Is there a way to get the parent ?


Maybe I have a Tree and wan't to go get the parent element (maybe a custom control)



Oct 6, 2011 at 5:50 PM

Hi Throndorin, have you ever discovered a way to do this? Thanks,

Oct 7, 2011 at 9:06 AM

no the only way I know is the way over AutomationElement

Oct 7, 2011 at 3:05 PM

I could never get child.AutomationElement.FindAll(Treescope.Ancestors, condition) to work because it says .Anscestors is not supported. Did you find another way via the AutomationElement? Thanks again

Oct 7, 2011 at 4:00 PM

have you tried:


Oct 7, 2011 at 4:04 PM

It seems that in order to get to the CachedParent, the parent must be instantiated first, cached, and then you can get back to it from it's children once you have gone down the tree. I haven't been able to go immediately up to the Parent using CachedParent when instantiating the child only. Have you had luck at all with this?

Oct 10, 2011 at 7:25 AM


in most cases I go down in the tree and get all elements to be sure I have the correct control. In our application i need to do so, because we have often controls paralell an the inner elements have the same automation ID and Name.


I have tried this one time and it has worked. But on other ways and custom controls not. Now it's clear why it has not worked.


Maybe the owner of White can give a short explanation..



Oct 12, 2011 at 1:55 AM
Edited Oct 12, 2011 at 1:56 AM

using System.Windows.Automation;

AutomationElement parent = TreeWalker.RawViewWalker.GetParent(child.automationelement)