Category / Section
How to scroll multiple items for one mouse wheel in WPF DataGrid (SfDataGrid)?
1 min read
You can scroll only one item while doing MouseWheel in WPF DataGrid (SfDataGrid). But you can scroll multiple items while doing MouseWheel by handling the DataGrid.PreviewMouseWheel event and calling the MouseWheelUp and MouseWheelDown based on the delta value.
Please refer the below code example for more details.
C#
this.dataGrid.PreviewMouseWheel += DataGrid_PreviewMouseWheel; private void DataGrid_PreviewMouseWheel(object sender, MouseWheelEventArgs e) { if (e.Delta == 0) return; if (e.Delta > 0) { (this.dataGrid.GetVisualContainer() as IScrollableInfo).MouseWheelUp(); (this.dataGrid.GetVisualContainer() as IScrollableInfo).MouseWheelUp(); (this.dataGrid.GetVisualContainer() as IScrollableInfo).MouseWheelUp(); (this.dataGrid.GetVisualContainer() as IScrollableInfo).MouseWheelUp(); } else { (this.dataGrid.GetVisualContainer() as IScrollableInfo).MouseWheelDown(); (this.dataGrid.GetVisualContainer() as IScrollableInfo).MouseWheelDown(); (this.dataGrid.GetVisualContainer() as IScrollableInfo).MouseWheelDown(); (this.dataGrid.GetVisualContainer() as IScrollableInfo).MouseWheelDown(); } }