Able to reset scrollbar postion in RadComboBox?

7 posts, 0 answers
  1. Frank
    Frank avatar
    6 posts
    Member since:
    Sep 2011

    Posted 16 Sep 2011 Link to this post

    Is there a way to programatically reset the position of the thumb in the vertical scrollbar to the top?  Example: the user pulls down the ComboBox's list and scrolls down to the bottom, then selects the bottom item.  After the list has been repopulated with a different set of items, I would like to have the thumb be back at the top of the list when the user reopens the ComboBox.  Currently, the position of the thumb does not get reset when the ComboBox's list is repopulated.  It remains at the same position it was at when the ComboBox closed, even when the items have been replaced.
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 21 Sep 2011 Link to this post

    Hi Frank,

    There is no way to reset the scrollbar position. If you have a selected item, however, the scroll position should automatically change so that the selected item is visible every time you open the dropdown.

    Best wishes,
    Valeri Hristov
    the Telerik team

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

  3. DevCraft banner
  4. Frank
    Frank avatar
    6 posts
    Member since:
    Sep 2011

    Posted 21 Sep 2011 Link to this post

    Ok, I see, thanks for the information Valeri.
  5. Daniel
    Daniel avatar
    5 posts
    Member since:
    Jun 2012

    Posted 23 Jan 2013 Link to this post

    I know this is a REALLY old thread to be posting to. But this is one of the first google search results for "silverlight radcombobox scroll to top" So i thought i'd post for anyone else having this problem.

    There is a workaround for resetting the scrollbar position in a RadComboBox. You just need to get the ScrollViewer from the template and scroll it to the top.

    If you're extending the RadComboBox, here's the code for it:
    public void ScrollToTop()
    {
        var scrollViewer = GetTemplateChild("PART_ScrollViewer") as ScrollViewer;
        if (scrollViewer != null)
        {
            scrollViewer.ScrollToVerticalOffset(0);
        }
    }

    If you're not extending the RadComboBox, you should be able to modify the code to fit your needs easily
  6. Prashant
    Prashant avatar
    1 posts
    Member since:
    Sep 2013

    Posted 02 Sep 2013 Link to this post

    Is there anyway to programatically reset the position of the thumb in the vertical scrollbar to the top?  Example: the user pulls down the ComboBox's list and scrolls down to the bottom, then selects the bottom item.  After the list has been repopulated with a different set of items, I would like to have the thumb be back at the top of the list when the user reopens the ComboBox.  Currently, the position of the thumb does not get reset when the ComboBox's list is repopulated.  It remains at the same position it was at when the ComboBox closed, even when the items have been replaced.

    Thanks in advance for the help .
  7. Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 03 Sep 2013 Link to this post

    Hello Prashant,

    There isn't built-in functionality in the ComboBox that allows you to reset the scrollbar position. However as an easy work-around I can suggest that in the method where you are inserting the new ComboBox items you could set the ComboBox SelectedItem to the first item of the collection in order to move the scrollbar up to the top. And if don't want any item to be selected you would just need to set the SelectedItem to null after that. Please see the code snippet below:

    comboBox.SelectedItem = comboBox.Items[0];
    comboBox.SelectedItem = null;

    Hope this will help you.

    Regards,
    Kalin
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  8. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 20 Dec 2013 Link to this post

    This only seems to work if I make the drop down visible
     comboBox.IsDropDownOpen = true;
    comboBox.SelectedItem = comboBox.Items[0];
    comboBox.SelectedItem = null;
     comboBox.IsDropDownOpen = false;


    Then it looks funny, cus it opens and closes.


    Sorry, suggest code works, but I have to put it in the DropDownOpened event.
Back to Top
DevCraft banner