RadTreeView inside a ScrollViewer

3 posts, 0 answers
  1. Edward
    Edward avatar
    2 posts
    Member since:
    Jun 2012

    Posted 09 Jan 2013 Link to this post

    I have a RadTreeView inside a ScrollViewer.

    When the mouse wheel is scrolled over the RadTreeView the parent ScrollViewer does not scroll.

    Is there an easy way to change this behavior that I'm missing (or a hard way for that matter)?

  2. Tina Stancheva
    Tina Stancheva avatar
    3299 posts

    Posted 10 Jan 2013 Link to this post

    Hello Edward,

    The RadTreeView control has a built-in ScrollViewer that wraps its children and it is designed to work with the mouse-wheel scrolling behavior out-of-the-box. This is why it isn't recommended to wrap the RadTreeView in yet another ScrollViewer. Instead please use the built-in one.

    Also, please note that the built-in RadTreeView ScrollBars will be displayed as soon as the control detects it needs more space to fully display its items. But in case you need to manually set the visibility of the ScrollBars and display them at all times, you can follow the steps outlined in this tutorial.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Edward
    Edward avatar
    2 posts
    Member since:
    Jun 2012

    Posted 10 Jan 2013 Link to this post

    The scenario I have involves the RadTreeView sharing the ScrollViewer along with other controls so your suggestion would not work in this case.

    I have however found a solution that involves re-raising the MouseWheel event on the parent object:

    private void RadTreeView_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
        if (!e.Handled)
            e.Handled = true;
            var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta);
            eventArg.RoutedEvent = UIElement.MouseWheelEvent;
            eventArg.Source = sender;
            var parent = ((Control)sender).Parent as UIElement;

    This seems to work well for me.

    Thanks for your help, Ed.

Back to Top