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

ScrollIntoView doesn't work

4 Answers 70 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
medialog
Top achievements
Rank 2
medialog asked on 18 Jun 2012, 12:16 PM
Hello,

When selected Index change,  I want to scroll automaticly on selected index.

So when selection change I call ScrollIntoView. With a ListBox it's work perfectly but with RadListbox it's doesn't work.

void ListBoxSelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
{
    if (SelectedItem != null)
        ScrollIntoView(SelectedIndex);
}

Any idea to fix it?


Thank by advance.

4 Answers, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 19 Jun 2012, 11:51 AM
Hi Jérôme,

We tried to reproduce the issue but with no success. Can you confirm that you are using the latest Q2 release version?

If you still experience the issue, please open a support ticket and send us sample project demonstrating the issue there.

Greetings,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Mike Krik
Top achievements
Rank 1
answered on 25 Jul 2012, 02:22 PM
I have the exact same problem, here is a sample project with a listbox containing a list of countries, I set the SelectedItem to United Kingdom and even though the selection is made correctly, you have to scroll down in order to see the selected item in the listbox even though i set the ScrollIntoView on SelectionChanged:

private void lbCountries_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (lbCountries.SelectedItem != null)
    {
        lbCountries.ScrollIntoView(lbCountries.SelectedIndex);
    }
}

Any ideas what i'm doing wrong?

Thanks in advance.

Mike
0
Vladi
Telerik team
answered on 27 Jul 2012, 03:49 PM
Hi Mike,

The issue you are having is that the SelectionChanged event is triggered before the ListBox control is loaded. The ListBox needs to be loaded first In order the ScrollIntoView method to work. All you need to do to fix the problem is to execute the logic you have in the SelectionChanged event handler from withing the Loaded event handler of the ListBox control. This way RadListBox control will be loaded when you need to call ScrollIntoView.

I have edited and attached your project for you. You can find it attached to this post.

Kind regards,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Mike Krik
Top achievements
Rank 1
answered on 16 Aug 2012, 06:53 PM
Thank you Vladi that solved my problem.

Cheers,

Mike
Tags
ListBox
Asked by
medialog
Top achievements
Rank 2
Answers by
Vladi
Telerik team
Mike Krik
Top achievements
Rank 1
Share this question
or