Navigating TreeViewItems in C#

I have written a number of tools for navigating our data in Dauntless. One of these tools gathers data about how our assets are referenced and the Unreal Engine pak files they go into for streaming installs for some platforms.

What I wanted to be able to do is from a particular node in the tree of assets (tree representation of a directed graph with cycles) was to search for a subnode (breadth first search) that matched search criteria by either name and/or chunk it belonged to (for cross-chunk references). Given the results of my search through my tree nodes and the collection of objects I then needed to navigate to the corresponding TreeViewItem and scroll to it.

If a TreeViewItem is collapsed, its visual children TreeViewItem instances may not be generated yet. This could might be simplified further based on the ItemContainerGenerator Status but I think it helps illustrate the stages.

My nodes are all based on a single type, the template parameter T. For more heterogeneous situations a base class, interface, or even just object would suffice.

Code follows.

Continue reading