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

RadListView not scrolling to pre-selected item

5 Answers 523 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Curtis asked on 24 Jul 2017, 07:00 PM

This is probably just me not knowing how to make this control do this but...

I have a list of items and in-code I'm selecting an item that off-screen but RadListView doesn't auto-scroll to that item.  it IS selected just not in view.

Do I have to do something like:  radListView1.ShowSelectedItem(someRadListDataItem)

or perhaps from the item itself?  Something that works like this:  someRadListDataItem.EnsureVisible = True

??

 

Any help would be appreciated.

-c

5 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 26 Jul 2017, 06:58 AM
Hello Curtis,

You can use the following methods:

this.radListBox.ScrollIntoView(this.radListBox.SelectedItem);
 
this.radListBox.ScrollIntoView(this.radListBox.SelectedIndex);


Regards,
Petar Mladenov
Progress Telerik
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
R
Top achievements
Rank 1
answered on 19 Mar 2020, 02:15 PM
How do we achieve this in MVVM?
0
Dinko | Tech Support Engineer
Telerik team
answered on 23 Mar 2020, 12:09 PM

Hello R A,

It depends on the scenario and when you want to call the ScrollIntoView() method. Basically, you can use Custom Attached Property and execute your logic in the property change method. Give this approach a try and let me know if it works for you.

Regards,
Dinko
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
R
Top achievements
Rank 1
answered on 23 Mar 2020, 12:57 PM

Thanks.

 

I see a property called "IsScrollIntoViewEnabled". Is this something related?

 

RA

0
Dinko | Tech Support Engineer
Telerik team
answered on 26 Mar 2020, 10:10 AM

Hi R A,

You are right. I have overlooked the first question in this thread, and I apologize for that. Yes, this property is related to the selected item. If an item is selected, it will automatically be scrolled into the view. This property is true by default. You could bind the SelectedItem property of the RadListBox to a custom property in your ViewModel. Then when you set the custom property to an item from the bound collection, which is outside the view, the control will bring it into the view automatically. The attached project demonstrates this behavior.

If you want to bring a specific item that is not selected into the view, you should use the ScrollIntoView() method.

Regards,
Dinko
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
ListBox
Asked by
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Petar Mladenov
Telerik team
R
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Share this question
or