Root node expand problem

8 posts, 1 answers
  1. Radu
    Radu avatar
    4 posts
    Member since:
    Apr 2009

    Posted 02 Jun 2009 Link to this post

    Hi everyone. I have problems on expanding the root node of the treeview at start. I do not use data binding and I have about 4 hierarhical levels. In code at runtime I call the ExpandAll() for the level 0 nodes but they do not expand. If I expand the level 0 nodes afterwards in the UI I can see that all other levels below are expanded.

  2. Answer
    Tihomir Petkov
    Admin
    Tihomir Petkov avatar
    576 posts

    Posted 03 Jun 2009 Link to this post

    Hello Radu,

    The ExpandAll method works after the UI elements of the treeview have been generated and you are probably calling the method before that has happened. In case you declare your treeview items in XAML, you can simply set the IsExpanded property of the root item to true. Alternatively, you can listen for RadTreeView's ItemPrepared event and programatically set the prepared item's IsExpanded property to true. In the second case you will only have to do this the first time the event occurs, because the event is fired for every item that is being rendered and after you expand the root item the event will be fired for every child item.

    Let me know if this helps and please do not hesitate to ask if you have further questions.

    Greetings,
    Tihomir Petkov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Radu
    Radu avatar
    4 posts
    Member since:
    Apr 2009

    Posted 03 Jun 2009 Link to this post

    Thanks a lot. It worked
  5. Maria Im
    Maria Im avatar
    10 posts
    Member since:
    Sep 2012

    Posted 21 Apr 2010 Link to this post

    It's a bit like Radu's problem but mine is different. I have the treevoew and Load on demand for each items like s

    1. Treatments
            2.VisitDate
                    3.Documents
                    3.Images
                    3.FreeHandNotes
    1.Treatments
           2.VisitDate
           2.VisitDate
                3.Documents
                3.Images
                3.FreehandNotes ..etc...

    As of Now, the treatments load fine. then if you click on Treatment it activates the Load on Demand and displays visit date and if you click VisitDate it will display {documents, images and freehand notes). Now I want to load it initially with the treatment expanded, showing only the VisitDate like so:

    1. Treatment 1
            2.VisitDate
    1.Treatment 2
            2.VisitDate
    1.Treatment 3
            2.VisitDate

    Under the item prepared event, I put the code so that the curreent item prepared IsExpanded property is set to True. But when it displays on the screen, only the last treatment is expanded while the first 2 treatments asre still trying to load. Please help.
  6. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 26 Apr 2010 Link to this post

    Hi Maria,

    I've prepared a sample project trying to mimic your scenario. I did not find any problems using the LoadOnDemand and expanding features. Could you please have a look at it and let me know if I am missing something. I'd be glad to further assist you.

    Best wishes,
    Kiril Stanoev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Maria Im
    Maria Im avatar
    10 posts
    Member since:
    Sep 2012

    Posted 26 Apr 2010 Link to this post

    Thanks. That answered my question.
  8. farhan iqbal
    farhan iqbal avatar
    5 posts
    Member since:
    May 2010

    Posted 06 May 2010 Link to this post

    I got a similar problem (with minor difference).
    I don't have any specific format of data, i.e. I had to load any XML file in my treeview, so I've to do this on runtime. What I do is, I manually create RadTreeViewItem and add it in the treeview in Window_Loaded event. A sample tree view could be:
    GrandFather
              Father1
              Father2
                    Child1
                    Child2
              Father3
                    Child1

    My problem is, if I had to expand a particular item (e.g., Father3 or GrandFather) RadTreeViewItem.IsExpanded = true not works for me, (either on window_Loaded or ItemPrepared)
  9. farhan iqbal
    farhan iqbal avatar
    5 posts
    Member since:
    May 2010

    Posted 06 May 2010 Link to this post

    sorry for posting the already posted problem, this will solve the issue:
    http://www.telerik.com/community/forums/wpf/treeview/item-selection-problem.aspx



Back to Top
UI for WPF is Visual Studio 2017 Ready