We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to restrict ScrollViewer mouse wheel scrolling, when mouse is over child control loaded in it?

Platform: WPF |
Control: UpDown |
.NET Framework: 4

ScrollViewer control helps to load, scroll and view child UI (WPF UpDown) elements more than screen bounds. But when mouse point is over its child controls and scroll action is performed, both the child controls and scroll viewer will scroll at the same time. It is possible to handle ScrollViewer wheel scrolling in this scenario and that can be done by using ScrollToVerticalOffset function.

For example

Here we have considered UpDown control as an example.

XAML

<ScrollViewer x:Name="scroll" PreviewMouseWheel="ScrollViewer_MouseWheel"  Focusable="False"> 
  <Grid> 
      <syncfusion:UpDown Height="50" Width="150" x:Name="updown"/> 
      <Button Height="50" Width="150" x:Name="updown1" Margin="175,322,175,-53"/> 
  </Grid> 
</ScrollViewer> 

C#

/// <summary> 
/// Invoked when the mousewheel on the ScrollViewer 
/// </summary> 
private void ScrollViewer_MouseWheel(object sender, MouseWheelEventArgs e) 
{ 
   if(updown.IsMouseOver) 
   { 
     scroll.ScrollToVerticalOffset(scroll.VerticalOffset); 
   } 
} 

Sample: UpDownSample

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile