문제

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!!

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top