Can not expandable nodes on non-Load nodes RadTreeView WPF(load-on demandable tree)

2 posts, 0 answers
  1. Nle41
    Nle41 avatar
    1 posts
    Member since:
    Jul 2013

    Posted 10 Jul 2013 Link to this post

    I m trying to expand and select related node on load on demand RadTreeView(telerik). but nodes are not expanded  if nodes are not loaded yet.I used the same codes  from

        var itemsControl = Tree as ItemsControl;
    var itemFound = true;

        while (itemsControl != null && itemFound)
    itemFound = false;
    var currentObject = ObjList.FirstOrDefault();

    for (int i = 0; i < itemsControl.Items.Count; i++)
    var treeElement = itemsControl.Items[i] as TreeElement;
    if (currentObject.Name == treeElement .Name)
    itemFound = true;
    BringIndexIntoView(itemsControl, i);
    var container = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as RadTreeViewItem;
    if (container != null)
    if (networkObjList.Count == 0)
    container.IsSelected = true;
    container.IsExpanded = true;


    itemsControl = container as ItemsControl;

    but non loaded nodes childs can not be filled. Why? could you help me?

    And also I wonder that How does a container know when a child has loaded?
  2. Hristo
    Hristo avatar
    352 posts

    Posted 15 Jul 2013 Link to this post


    I see you are using an article from our help that has not been properly updated through the years. We are very sorry for caused inconvenience and shall update the article to describe the best and most straightforward approach.

    Meanwhile, I would like to suggest you use the BringPathIntoView feature of RadTreeView. You could find more info in the following article. The basic idea is to provide a full path from root to required item and RadTreeView will perform necessary expand and scroll operations in order to bring the item into view.
    Additionally if you would like to select the item the best approach would be to use a binding to the IsSelected property as described in the following article.
    Finally, I see you would like to use load on demand. This feature is targeting the scenario when user hits the expand arrow of particular item and the item currently does not have any children with concerns to performance. This will give the developer a chance to lazy load the required items and notify back the RadTreeView that items has been loaded.
    In addition, when you would like to programmatically navigate to some item that has not yet been loaded you would have to load it manually. The load on demand will not take care to properly load required items. I.e. you would have to manually fill the required items' children collections. Then, after the data item has been loaded in the appropriate place (in RadTreeView items source) you could call the BringPathIntoView method and select the item programmatically (using the IsSelected binding to the view model).

    Don't hesitate to contact us should you need more info on the topic.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top