4

I've got a TreeView in a WPF Application which has an Index that is changed outside of the TreeView itself.

How can I use a ScrollIntoView (such a function like for DataGrid) option for such a TreeView when it is out of Focus?

Thanks a lot.

0

1 Answer 1

10

Try using the Expanded event of the TreeView like this:

private static void TreeView1_Expanded(object sender, RouterEventArgs e)
{
    var tvItem = (TreeViewItem)e.OriginalSource;
    var itemCount = VisualTreeHelper.GetChildrenCount(tvItem)

    for (var i = itemCount-1; i>=0; i--)
    {
        var child = VisualTreeHelper.GetChild(tvItem, i);
        ((FrameworkElement)child).BringIntoView();
    }
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.