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.
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();
}
}