Konstantin Weitz
Konstantin Weitz

Reputation: 6432

Keeping the TreeView and the Nodes separate

I have a problem concerning good application design that has been keeping me up for days now. One can describe it as:

So where do I store the information whether an node is expanded or not (this information is not part of the Node itself).

Any idea on how to implement this in a clean way?

Thanks,
Konne

Upvotes: 1

Views: 646

Answers (2)

Aravind Yarram
Aravind Yarram

Reputation: 80194

Create a TreeViewModal class that binds the view and the actual modal. Apparently this is known as Model/View/ViewModel pattern. Here is an example for the TreeView. Both the links has code in C# but it is easy to port to any language.

Upvotes: 1

David Harkness
David Harkness

Reputation: 36552

If each node has a unique hashable key you could add a hash table to TreeView to contain the keys of the expanded nodes.

Upvotes: 0

Related Questions