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

RadTreeView inside a ScrollViewer

2 Answers 495 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Edward
Top achievements
Rank 1
Edward asked on 09 Jan 2013, 05:04 PM
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)?

Ed

2 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 10 Jan 2013, 10:29 AM
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.

1
Edward
Top achievements
Rank 1
answered on 10 Jan 2013, 04:35 PM
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;
        parent.RaiseEvent(eventArg);
    }
}

This seems to work well for me.

Thanks for your help, Ed.

Tags
TreeView
Asked by
Edward
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Edward
Top achievements
Rank 1
Share this question
or