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

Scroll problem when Grid's cell contains TreeView

2 Answers 231 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jakub
Top achievements
Rank 1
Iron
Jakub asked on 14 Aug 2017, 10:12 AM

Hi,

I have a little problem with my scroll on RadGridView. One of my column's cell template is RadTreeView. When mouse is over tree, mouse-wheel move does not take affect on RadGridView scroll. When mouse is over any other cell, mouse-wheel scroll works correct, like always. It looks like RadTreeView inside cell is stealing mouse-wheel event and RadGridView doesn't scroll? Because my cell height is adjusting itself to RadTreeView size, there is no scroll bars inside cell, it is ok, I want scroll only on RadGridView.

 

Thanks for any help!

2 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 17 Aug 2017, 09:05 AM
Hello Jakub,

Thank you for contacting us.

What I can suggest you is to subscribe to the PreviewMouseWheel event of the RadTreeView. In the event handler, you can handle the event and raise the event to its parent. This way when you are over a tree view its parent will be scrolled, which in your case is the RadGridView control.
<telerik:RadTreeView PreviewMouseWheel="RadTreeView_PreviewMouseWheel"/>
private void RadTreeView_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
    if (!e.Handled)
    {
        e.Handled = true;
        var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) { RoutedEvent = MouseWheelEvent, Source = sender };
        var parent = ((Control)sender).Parent as UIElement;
        if (parent != null)
        {
            parent.RaiseEvent(eventArg);
        }
    }
}

I have created sample project which demonstrates the above approach and attached it to this reply.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Jakub
Top achievements
Rank 1
Iron
answered on 21 Aug 2017, 10:37 AM

Hi Dinko,

works as it should, thanks a lot!

Tags
GridView
Asked by
Jakub
Top achievements
Rank 1
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Jakub
Top achievements
Rank 1
Iron
Share this question
or