New to Telerik UI for Xamarin? Download free 30-day trial

Programmatic Scrolling

RadTreeView exposes the following method for programmatic scrolling to a specific data item:

  • bool ScrollItemIntoView(object item): Attempts to bring the specified data item into the view. Returns false in case the item is not available (cannot be found in the ItemsSource or any of its parents is not expanded).


Here is a sample definition of the TreeView control:

        <RowDefinition Height="Auto"/>
        <Button Clicked="ScrollItemIntoViewClicked" Text="ScrollItemIntoView"/>
        <Label x:Name="label"/>
    <telerikDataControls:RadTreeView x:Name="treeView" Grid.Row="1" ItemsSource="{Binding Source}">
        <telerikDataControls:TreeViewDescriptor DisplayMemberPath="Name"
                                                TargetType="{x:Type local:Item}"/>

Inside ScrollItemIntoViewClicked event handler get the concrete item you'd need to navigate to and call ScrollItemIntoView method of the TreeView:

private void ScrollItemIntoViewClicked(object sender, EventArgs e)
    var item = GetItemToScroll();
    if (this.treeView.ScrollItemIntoView(item))
        this.label.Text = "Scrolled to: " + item;
        this.label.Text = item + " is either collapsed or does not exist";
private Item GetItemToScroll()
    return ((treeView.ItemsSource as ObservableCollection<Item>).LastOrDefault() as Item).Children.LastOrDefault();

And the end result:

Figure 1: Scrolling item into View

You can check a runnable demo in the Features section of the RadTreeView component in the SDK Samples Browser application(can be found in the Examples folder of your local Telerik UI for Xamarin installation)

See Also

In this article