This is a migrated thread and some comments may be shown as answers.

BringPathIntoView Not Working With ExpandAll

2 Answers 126 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Scott Michetti
Top achievements
Rank 1
Iron
Scott Michetti asked on 01 Oct 2015, 04:19 PM

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 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 02 Oct 2015, 02:44 PM
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
0
Scott Michetti
Top achievements
Rank 1
Iron
answered on 06 Oct 2015, 07:03 PM

Thanks Dinko,

that helped.

Tags
TreeView
Asked by
Scott Michetti
Top achievements
Rank 1
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Scott Michetti
Top achievements
Rank 1
Iron
Share this question
or