WPF find column index of textblock inside visual tree

66 Views Asked by At

I want to calculate enter image description here automation id of text block inside the content presenter. My visual tree looks like this-

1

There are 1 best solutions below

0
Maxim On

You can use System.Windows.Media.VisualTreeHelperto determine any control in visual tree. There are two helpful methods

System.Windows.Media.VisualTreeHelper.GetParent(DependencyObject reference)

to go up in tree hierarchy

System.Windows.Media.VisualTreeHelper.GetChiled(DependencyObject refernce, int childIndex)

to go down in tree hierarchy See more: VisualTreeHelper