Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
270
XamOrgChart Expand
posted

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

 

Parents
No Data
Reply
  • 138253
    Offline posted

    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.

Children
No Data