MattNiznak
Topic Author
Posts: 6
Joined: 14 Oct 2019, 10:17

Walking a TreeView

07 Apr 2020, 01:51

Is it possible to get the root node of the TreeView, iterate over it's children, find their parents, children, and get values related to their elements?

The problem that I'm trying to solve is that I have an external tree data structure that I'd like the treeview to mirror, as well as be able to make changes and push any changes in that relationship back to the original tree data structure.

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 1911
Joined: 22 Dec 2011, 19:20

Re: Walking a TreeView

07 Apr 2020, 13:42

There are some useful function in the VisualTreeHelper class to navigate visual tree. Analog to that there is a LogicalTreeHelper to navigate the logical tree.
You can also use ItemsControl.ItemsControlFromItemContainer() to find parent ItemsControl for TreeViewItems. With this function you can reach the top TreeView from any TreeViewItem.

Please let me know if that helps.

Who is online

Users browsing this forum: No registered users and 0 guests