This is a migrated thread and some comments may be shown as answers.

Scroll SelectedItem to Top of TreeListView

3 Answers 197 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Lakshman
Top achievements
Rank 1
Lakshman asked on 27 Dec 2016, 11:49 AM

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

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 29 Dec 2016, 02:47 PM
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.
0
Lakshman
Top achievements
Rank 1
answered on 30 Dec 2016, 06:10 AM
Thanks Ivan for the reply, i will try and let you know the behaviour.
0
Lakshman
Top achievements
Rank 1
answered on 03 Jan 2017, 02:19 PM
Thanks Ivan for the reply. It works and fixes some of my problems.
Tags
TreeListView
Asked by
Lakshman
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Lakshman
Top achievements
Rank 1
Share this question
or