1
votes

Consider a large TreeView; some nodes and subnodes are expanded others are collapsed. The user adds a child node to a node and the program saves everything back to the underlying XML file. Then the TreeView rebuilds. The problem is that only the root node is expanded; all other nodes are collapsed.

Has anybody ever seen code (I don't think there's anything built into WPF that does this) that saves the state of the TreeView (which nodes are expanded) and then is able to restore it to this state after a save?

Any ideas?

Edit

Well, that link didn't really help. I'm thinking of creating an array and storing the state of isExpanded and then reading it back after the load.

1
Maybee this post can help you stackoverflow.com/questions/3989018/…live2
Thanks! That should help!zetar
Would you explain why the linked approach was not helpful?Ron

1 Answers

0
votes

One has to manage the treeview's states directly and note when a node is expanded or collapsed. Then on load or refresh, open / close the nodes as needed.