Scroll SelectedItem to Top of TreeListView

4 posts, 1 answers
  1. Lakshman
    Lakshman avatar
    8 posts
    Member since:
    Dec 2016

    Posted 27 Dec 2016 Link to this post

    Hi,

    I am using RadTreeListView with (LazyLoading), to populate the hierarchical items in tree structure. I have a requirement to bring the selected item to top of RadTreeListVIew. I had tried ScrollToVerticalOffset/ScrollIndexIntoView/ScrollIntoViewAsync but these APIs does not help my requirement. All these APIs just bring the item to the view but not to the top of the TreeList. Please let us know how to achieve the same.

     

    The tree has almost 20000 items in hierarchical manner.

     

    Thanks in Advance,

    Lakshman Siddireddy

  2. Answer
    Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1200 posts

    Posted 29 Dec 2016 Link to this post

    Hi Lakshman,

    RadTreeListView's UI virtualization logic uses an internal algorithm to calculate the vertical offset of every road. However, if you application uses rows with the same row height, you can calculate the offset of the newly selected item and then scroll vertically to it like this:

    private void OnSelectionChanged(object sender, SelectionChangeEventArgs e)
    {
        if (this.scrollViewer == null)
        {
            this.scrollViewer = clubsGrid.ChildrenOfType<ScrollViewer>().FirstOrDefault();
        }
     
        this.scrollViewer.ScrollToVerticalOffset(clubsGrid.Items.IndexOf(e.AddedItems[0]) * clubsGrid.RowHeight);
    }

    Regards,
    Ivan Ivanov
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Lakshman
    Lakshman avatar
    8 posts
    Member since:
    Dec 2016

    Posted 30 Dec 2016 Link to this post

    Thanks Ivan for the reply, i will try and let you know the behaviour.
  4. Lakshman
    Lakshman avatar
    8 posts
    Member since:
    Dec 2016

    Posted 03 Jan Link to this post

    Thanks Ivan for the reply. It works and fixes some of my problems.
Back to Top