WPF Diagram Expand/Collapse Levels

Hi,

I want to show two buttons outside diagram area and implement expand/collapse feature. When you click on buttons, graph nodes should expand/collapse level by level from a given root node.

ex:
Collapse click one - collapse all the leaf nodes of the tree from given root node, now parents of each leaf node become a leaf node.
Collapse click two - collapse all current leaf nodes, parent of leaf become the leaf… so on
and expand should do the opposite.

Is it possible to do this with GoXamp library? How easy/hard to do it? Appreciate if you could point me at the right direction and would be great if there is a sample code too(I’ve checked samples and there is a sample to put a expand/collapse button near a node. My requirement is bit different and it involves finding the depth of the graph based on a given root node.).

Thanks.

I think expanding is a matter of finding all of the Nodes that have Node.IsExpandedTree false, and then iterating through those and calling Node.ExpandTree.

Collapsing is basically the same, except you want to collect all of the Node.IsExpandedTree nodes and then call Node.CollapseTree on each.

Everything should be performed within a single transaction. I recommend collecting all of the not IsExpandedTree nodes first, before calling ExpandTree on any one of them, to avoid finding and expanding a just-expanded child node.

http://www.goxam.com/2.2/helpWPF/webframe.html#Northwoods.GoWPF~Northwoods.GoXam.Node~IsExpandedTree.html
http://www.goxam.com/2.2/helpWPF/webframe.html#Northwoods.GoWPF~Northwoods.GoXam.Node~ExpandTree.html

Thanks, I ended up adding expand/collapse all instead of level by level expand/collapse.