ListBox攔截滾輪ScrollViewer滾動事件
阿新 • • 發佈:2018-12-07
<ScrollViewer >
<ListBox x:Name="CommentListBox" >
</ListBox>
</<ScrollViewer >
滾輪影響可修改
<ScrollViewer > <ListBox x:Name="CommentListBox" PreviewMouseWheel="CommentListBox_OnPreviewMouseWheel"> </ListBox> </<ScrollViewer >
https://stackoverflow.com/questions/1585462/bubbling-scroll-events-from-a-listview-to-its-parentprivate void CommentListBox_OnPreviewMouseWheel(object sender, MouseWheelEventArgs e) { if (e.Handled) return; e.Handled = true; var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) { RoutedEvent = UIElement.MouseWheelEvent, Source = sender }; var parent = ((Control)sender).Parent as UIElement; parent?.RaiseEvent(eventArg); }