在 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}"