expand TreeViewList

7 posts, 1 answers
  1. KK
    KK avatar
    5 posts
    Member since:
    Aug 2012

    Posted 31 Dec 2010 Link to this post

    Hello,
    I am using TreeviewList in my WPF appication using MVVM. I want to show all nodes in expanded mode but by default it shows me only parent node. Is there any way to show all nodes (in expanded mode) automatically?
  2. Answer
    Nikolay
    Admin
    Nikolay avatar
    3997 posts

    Posted 31 Dec 2010 Link to this post

    Hi KK,

    I suggest you check the following help article that should get you started:
    http://www.telerik.com/help/wpf/treelistview-expand-all-hierarchy.html

    Hope this helps.

    All the best,
    Nick
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  3. UI for WPF is Visual Studio 2017 Ready
  4. Cheau-Long
    Cheau-Long avatar
    27 posts
    Member since:
    Jan 2011

    Posted 11 Mar 2011 Link to this post

    Hi Telerik,

    I have a similar question in expanding the tree. I followed the example and was able to expand the tree when View was first initialized. However, if the entire collection was changed, I wasn't able to fire the event to expand the tree. I'm using MVVM model. The collection was implemented as ObservableCollection. I have to re-create the view in order to fire the event. Is there a event in TreeViewList when the data is completed?

           public PipeSegmentView()
            {
               this.pipeTreeListView.DataLoaded += new EventHandler<EventArgs>(pipeTreeListView_DataLoaded);
            }
     
            private void pipeTreeListView_DataLoaded(object sender, EventArgs e)
            {
                this.pipeTreeListView.DataLoaded -= new EventHandler<EventArgs>(pipeTreeListView_DataLoaded);
                this.pipeTreeListView.ExpandAllHierarchyItems();
            }        
    
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 12 Mar 2011 Link to this post

    Hello Cheau-Long,

    I have tried to reproduce the issue you reported, but I was not able to. I am sending you the sample project I used for the test. Please take a look at it and let me know in case of any misunderstandings.

     

    Best wishes,
    Maya
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  6. Cheau-Long
    Cheau-Long avatar
    27 posts
    Member since:
    Jan 2011

    Posted 14 Mar 2011 Link to this post

    Hi Maya,

    Thanks for the quick response! The DataLoad event worked just fine to expand the tree, I actually referred to how to re-expand the tree if the datasource was reloaded with a different set of data. Please find the attached modification of your example. In the example, you will see "Refresh Data" button, which will fetch a different tree-like data (GetClubs2). Because the DataLoaded event was removed after the data was loaded, the event won't be fired again. I tried to take keep this event, but error occurred when the entire datasource was updated.
    		void RadTreeListView1_DataLoaded(object sender, EventArgs e)
    		{
    			this.RadTreeListView1.DataLoaded -= new EventHandler<EventArgs>(RadTreeListView1_DataLoaded);
    			this.RadTreeListView1.ExpandAllHierarchyItems();   
    		}
    
    
    My question is how to re-trigger this event, if the data model is updated. I have a RoutedCommand that will update the datasource in the VM, and not using the codebehind as I did in the example.

    Thanks for helping!
    Cheau-Long
  7. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 15 Mar 2011 Link to this post

    Hello Cheau-Long,

    Generally, the idea behind calling the ExpandAllHierarchyItem() method in the DataLoaded event is that you need to make sure all the elements are loaded as well as the items themselves. 
    You mentioned that you updated the sample project I attached previously, but unfortunately I am not able to see any files attached. May you try to resend it so that I can see your exact requirements ? 
    Basically, I have tested the sample by handling a Click event of a button, changing the ItemsSource there and calling that very method. However, it all works appropriately and the parent rows are expanded. Is that the scenario you tried ? 

     

    All the best,
    Maya
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  8. Mark
    Mark avatar
    44 posts
    Member since:
    Jun 2009

    Posted 12 Sep 2011 Link to this post

    Hi Cheau-Long,

    I am faced with this challenge as well.  Did you manage to find a suitable solution? 

    Thanks,
    Mark
Back to Top
UI for WPF is Visual Studio 2017 Ready