WPF在可视树中查找textblock的列索引

WPF在可视树中查找textblock的列索引,wpf,textblock,visual-tree,Wpf,Textblock,Visual Tree,我想计算内容演示器内文本块的自动化id。我的可视化树如下-您可以使用System.Windows.Media.visualtreeheloper确定可视化树中的任何控件。 有两种有用的方法 System.Windows.Media.VisualTreeHelper.GetParent(DependencyObject引用) 在树层次结构中上升 System.Windows.Media.VisualTreeHelper.GetChiled(DependencyObject引用,int childI

我想计算内容演示器内文本块的自动化id。我的可视化树如下-

您可以使用
System.Windows.Media.visualtreeheloper
确定可视化树中的任何控件。 有两种有用的方法

System.Windows.Media.VisualTreeHelper.GetParent(DependencyObject引用)

在树层次结构中上升

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

在树层次结构中向下移动 请参阅更多: