Hi crosslife,
Based on the information provided, we understand that you would like to enable horizontal scrolling using the Shift key and mouse wheel, while retaining vertical scrolling with the mouse wheel alone.
By default, the Spreadsheet control does not support horizontal scrolling via Shift + mouse wheel. However, this functionality can be achieved by customizing the ScrollViewer.PreviewMouseWheel event.
Code Snippet for customizing the ScrollViewer.PreviewMouseWheel event:
private void SpreadsheetOnLoaded(object sender, RoutedEventArgs e) { var spreadsheet = sender as SfSpreadsheet; var spreadsheet = sender as SfSpreadsheet; if (spreadsheet != null && spreadsheet.ActiveGrid != null && spreadsheet.ActiveGrid.Template!=null) { var scrollViewer = spreadsheet.ActiveGrid.Template.FindName("PART_ScrollViewer", spreadsheet.ActiveGrid) as ScrollViewer; if (scrollViewer != null) { scrollViewer.PreviewMouseWheel += ScrollViewer_OnPreviewMouseWheel; } } private void ScrollViewer_OnPreviewMouseWheel(object sender, MouseWheelEventArgs e) { var scrollViewer = sender as ScrollViewer; if (scrollViewer != null) { if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) { scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset - e.Delta); e.Handled = true; } } } |
Find the sample demo in the attachment.
Please let us know if you have any concerns in this.
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Regards,
Malini Selvarasu
Attachment:
SfSpreadSheet_Demo_ddb74fbd.zip