Scroll to top when showing menu

2 posts, 0 answers
  1. Chris
    Chris avatar
    11 posts
    Member since:
    Apr 2014

    Posted 02 Apr 2015 Link to this post

    I have a RadRibbonDropDownButton that has the DropDownContent set to a RadContextMenu. The RadContextMenu contains menu items some of which contain sub menu items. Some of the submenus contain a large number of items and use scrolling to display all of them.

    If a scroll down to the bottom of one of the sub menus to select and item and then go back into that sub menu, I would like it to be scrolled back to the top. However, it seems to remember the last scroll position and is still scrolled to the bottom. Is there a way to change this so that the scroll position is not remembered, and the submenu is also scrolled to the top when it is opened.

    The menu items and submenu items are constructed dynamically using data binding, so I have a reference to the RadContextMenu, but not to any of the menu items it contains.
  2. Nasko
    Nasko avatar
    698 posts

    Posted 06 Apr 2015 Link to this post

    Hi Chris,

    In order to return the ScrollViewer to Top as soon as RadContextMenu is open, we suggest you to handle the Loaded event of the control. Inside it you could get the ScrollViewer using the FindName method and call its ScrollToTop method, as shown below:

    private void radContextMenu_Loaded(object sender, RoutedEventArgs e)
    //'menuItem' is named the item that contains a collection of MenuItems that causes the ScrollViewer to be visualized
        var scrollViewer = this.menuItem.Template.FindName("PART_ScrollViewer", this.menuItem) as ScrollViewer;

    Hopes this helps.


    See What's Next in App Development. Register for TelerikNEXT.

Back to Top