Hey!
My first issue is the following:
I bind my OrgChart's DataContext to a ViewModel.
I want all nodes be collapsed when the Chart is shown first time.
I tried:
Dim allNodes = NetzChart.RootNode.HighlightChildren(NetzChart.ActualDepth)
For Each node As OrgChartNode In allNodes
node.IsExpanded = False
Next
But that throws an StackOverflowException even with small data, or does not show the orgChart at all.
My second issue:
Is there a OnNodeExpanded Event or something similar to that? Or any workaround to achieve this behaviour? I want not to load the childs of one node of the chart until the parentnode is expanded by the user.
Thanks for your help!
Regards
Henning
Hello Henning,
Thank you for your post. I have been looking through it and I suggest you use a recursive function in order to iterate trough all nodes of the XamOrgChart. The function may look like this:
private void Iterate(OrgChartNode node) { if (node.ChildNodes != null) { foreach (var item in node.ChildNodes) { Iterate(item); } } if(node.Level != 0) node.IsExpanded = false; }
And you can call it in the Loaded event of the XamOrgChart with its RootNode as argument. As for your other question I can suggest you use the NodeControlAttached event of the control, which occurs when a Node is Expanded or Collapsed.
Feel free to write me if you need further assistance on this matter.