I have a base class derived from MvvmLight.ViewModelBase with additional responsibilities to handle object selections. This class defines a RelayCommand<MouseButtonEventArgs>
property which is bound in the View:
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDown">
<galaxcmd:EventToCommand Command="{Binding SelectCommand,Mode=OneWay}" PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
This view is used multiple times inside a containing view that I now need to handle mousedowns too. My issue arises because I don't want the container to handle mousedown if it was handled by a contained view. I thought the PassEventArgsToCommand was my solution to this problem because I planned a child VM to just set MouseButtonEventArgs.Handled = true
. Unfortunately, the MouseButtonEventArgs argument is always null. Just in case, I also tried RoutedEventArgs and even EventArgs, but they're all null too.
What am I doing wrong with EventToCommand (or EventTrigger?)?
您可以在此处找到基于EventToCommand
的经过修改的EventToCommand
实现,您可以在其中将Eventargs
设置为CommandParameter
并停止事件路由。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.