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

Scroll to top when showing menu

1 Answer 803 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 02 Apr 2015, 07:36 PM
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.

1 Answer, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 06 Apr 2015, 03:56 PM
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;
    scrollViewer.ScrollToTop();
}

Hopes this helps.

Regards,
Nasko
Telerik
 

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

 
Tags
ContextMenu
Asked by
Chris
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Share this question
or