Mousewheel scroll issue in PanelBaritem

1 Answer 45 Views
PanelBar
Priya
Top achievements
Rank 1
Iron
Iron
Iron
Priya asked on 13 May 2022, 04:51 PM

I have a panelbaritem that contains a grid. When the grid is expanded I get the scrollbar as expected. I am able to scroll up/down by dragging the scrollbar button up/down. However, I cannot use the mousewheel to scroll.

Is there any special setting to enable mouse wheel scrolling.

Just to make sure that it is not a problem with my project, I created a small test project and see the same behavior.

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 18 May 2022, 10:47 AM

Hello Priya,

I was able to reproduce this with a sample RadGridView control inside a RadPanelBarItem element. This occurs due to the ScrollViewer element, which is inside the default control template of the RadPanelBarItem control.

With this being said, what comes to my mind, in order to achieve the desired result, would be to subscribe to the PreviewMouseWheel event of the RadPanelBarItem control. Then, you could raise the MouseWheel event of the parent RadPanelBar element.

The following code snippet shows this suggestion's implementation:

<telerik:RadPanelBarItem Header="PanelBar Item 1" 
                         PreviewMouseWheel="RadGridView_PreviewMouseWheel">
    <telerik:RadGridView ItemsSource="{Binding DataModels}"/>
</telerik:RadPanelBarItem>
private void RadGridView_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 parentPanel = ((RadPanelBarItem)sender).ParentOfType<RadPanelBar>();

        if (parentPanel != null)
        {
            parentPanel.RaiseEvent(eventArg);
        }
    }
}

The produced result is as follows:

Could you give this suggestion a try?

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Priya
Top achievements
Rank 1
Iron
Iron
Iron
commented on 26 May 2022, 09:16 PM

Hi Stenly,

That worked!. Thank you.

Tags
PanelBar
Asked by
Priya
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or