I'm trying to write code that can accept Key.Down and Key.Up and change the selection of a TreeView that is using several HierarchicalDataTemplates. In the children of a TreeViewItem, I need to get its parent so that I can determine what the next node should be selected. I noticed that TreeViewItem has a ParentTreeViewItem property, but its set to internal and therefore not exposed to access. Is there another way to emulate how to get the parent of a TreeViewItem as a TreeViewItem? Note: Parent is always null when using HierarchicalDataTemplate. Thanks in advance.
TreeViewItem.ParentTreeViewItem is internal but is there a way to get it?
135 Views Asked by RevitArkitek At
2



You can always use the
VisualTreeHelper.GetParentto find any parent element:Usage Example