RadiantQ WPF Gantt
How to expand a specific node in the heirarchical list?
Previous Topic  Next Topic 

How to expand a specific node in the heirarchical list?


This topic discusses how to keep nodes collapsed on load.


Then if you want to expand a specific node on load, you can do this:


a) To get hold of the 1st parent in the hierarchy.

       // First listen to TemplateApplied        

       private void GanttControl_TemplateApplied(object sender, EventArgs e)

       {                

             GanttControl.FlexyTree.Loaded += FlexyTree_Loaded;

       }


        void FlexyTree_Loaded(object sender, RoutedEventArgs e)

        {

            FlexyTree tree = sender as FlexyTree;

            // Get hold of a specific item.

            object tvi = tree.ItemContainerGenerator.ContainerFromIndex(0);

           

            // Do anything else necessary before you set IsExpanded to true below.

           

            ((TreeViewItem)tvi).IsExpanded = true;

        }



b) To get hold of a TreeViewItem corresponding to a data object in your bound view model:


       // First listen to TemplateApplied        

       private void GanttControl_TemplateApplied(object sender, EventArgs e)

       {                

             GanttControl.FlexyTree.Loaded += FlexyTree_Loaded;

       }


        void FlexyTree_Loaded(object sender, RoutedEventArgs e)

        {

            FlexyTree tree = sender as FlexyTree;

            // Get hold of a specific item.

            object tvi = tree.ItemContainerGenerator.ContainerFromItem(/*A reference to the item in your view model that's rendered as a node in the top level in the hierarchy list*/);

           

            // Do anything else necessary before you set IsExpanded to true below.

           

            ((TreeViewItem)tvi).IsExpanded = true;

        }




� RadiantQ 2009 - 2019. All Rights Reserved.