BringPathIntoView Not Working With ExpandAll

3 posts, 0 answers
  1. Scott Michetti
    Scott Michetti avatar
    92 posts
    Member since:
    Feb 2010

    Posted 01 Oct 2015 Link to this post

    Hello,

    after I load the tree I want to expand all items, then call BringPathIntoView(). This does not work. If I do not call ExpandAll(), BringPathIntoView will select the correct item. My requirement is that I expand the whole tree and select a specific item based on certain rules. Here's my code:

     radTreeView.ItemsSource = _radTreeViewItems;

    radTreeView.ExpandAll();

    radTreeView.BringPathIntoView("something\\somethingChild");

     

    The "something\\somethingChild" path is an item near the bottom of a large tree and it does not scroll down. Is there a way to wait for the ExpandAll() method to finish, then call BringPathIntoView?

     

    Thanks,

    Scott

  2. Dinko
    Admin
    Dinko avatar
    204 posts

    Posted 02 Oct 2015 Link to this post

    Hello Scott,

    In order to achieve the desire effect you can call ExpandAll() method in the constructor in the MainPage constructor then you can call BringPathIntoView() method in the event handler of the  TreeView Loaded event.
    public MainPage()
    {
        InitializeComponent();
        myTreeView.ExpandAll();
        myTreeView.Loaded += myTreeView_Loaded;
    }
    private void myTreeView_Loaded(object sender, RoutedEventArgs e)
    {
        // example path
        string path = "0\\0.3\\0.3.0\\0.3.0.1";
     
        Dispatcher.BeginInvoke(new Action(() =>
        {
            myTreeView.BringPathIntoView(path);
        }), DispatcherPriority.Background);
    }
    To make this work properly you will need to call the BringPathIntoView() method into a Dispatcher with its DispatcherPriority set to Background.

    If this solution is not the answer you are looking for don't hesitate to contact us.

    Regards,
    Dinko
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Scott Michetti
    Scott Michetti avatar
    92 posts
    Member since:
    Feb 2010

    Posted 06 Oct 2015 in reply to Dinko Link to this post

    Thanks Dinko,

    that helped.

Back to Top