wpf CommandParameter 传递MouseWheelEventArgs参数 ,用 MvvmLight 实现
在 WPF 中使用 MVVM Light 框架传递 MouseWheelEventArgs
参数至 CommandParameter
,可通过以下步骤实现:
1. XAML 中配置事件绑定
在控件上通过 EventToCommand
绑定鼠标滚轮事件,并启用 PassEventArgsToCommand
属性以传递事件参数:
<!-- 命名空间声明 -->
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:mvvm="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"<控件类型(如 Grid/ListView)><i:Interaction.Triggers><i:EventTrigger EventName="MouseWheel"><mvvm:EventToCommand Command="{Binding YourMouseWheelCommand}"