ScrollIntoView doesn't work

5 posts, 0 answers
  1. medialog
    medialog avatar
    25 posts
    Member since:
    Sep 2010

    Posted 18 Jun 2012 Link to this post

    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.
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 19 Jun 2012 Link to this post

    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 >>

  3. DevCraft banner
  4. Mike Krik
    Mike Krik avatar
    2 posts
    Member since:
    Jul 2012

    Posted 25 Jul 2012 Link to this post

    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
  5. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 27 Jul 2012 Link to this post

    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.

  6. Mike Krik
    Mike Krik avatar
    2 posts
    Member since:
    Jul 2012

    Posted 16 Aug 2012 Link to this post

    Thank you Vladi that solved my problem.

    Cheers,

    Mike
Back to Top
DevCraft banner