Question

I am using a Wpf TreeView, in which I am adding nodes at runtime. Some times tree goes bigger and ScrollViewer comes into picture(that is part of TreeView's ControlTemplate). But everytime I add a node, I can not see it, cos it is outside the page area, I need to drag the vertical ScrollBar's thumb down in order to see it. so I want the vertical ScrollBar to automatically drag to the point where the node is added so that I can see the node while adding it.

Any help please!!

Was it helpful?

Solution

you should be able to use BringIntoView to bring your new item into view, within any scrollable regions it is contained within. Pls, check an example below:

TreeViewItem item = new TreeViewItem() {  Header = "test" };
treeView1.Items.Add(item);
item.BringIntoView();

hope this helps, regards

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top