How to autoscroll for viewing a newly added item in WPF TreeViewAdv?
This article describes how to autoscroll for viewing a newly added item in WPF TreeViewAdv control.
BringIntoView
Use BringIntoView method of TreeViewAdv control to scroll and view a particular item.
Use Button Click event to add items
to TreeViewItemAdv of TreeViewAdv control.
The following code demonstrates the same by passing newly added item as argument to BringIntoView method.
<syncfusion:TreeViewAdv Name="tree">
<syncfusion:TreeViewItemAdv Header="Parent Tree"
FontSize="18">
</syncfusion:TreeViewItemAdv>
</syncfusion:TreeViewAdv>
<Button Grid.Column="1"
HorizontalAlignment="Center"
Height="40"
Width="100"
FontSize="18"
Click="ButtonClick">
Click here
</Button>private void ButtonClick(object sender, EventArgs e)
{
TreeViewItemAdv treeitem = new TreeViewItemAdv();
treeitem.Header = "Tree" + ((tree.Items[0] as TreeViewItemAdv).Items.Count + 1).ToString();
(tree.Items[0] as TreeViewItemAdv).Items.Add(treeitem);
tree.BringIntoView(treeitem);
}The output for the above code is shown below:
