我有一个按钮,需要执行两个不同的命令(一个启动某些东西,另一个停止它)。经过一些研究,System.Windows.Interactivity.dll似乎提供了一种简单的方法来实现这一点。但是它不适用于左鼠标按钮(如果我使用MouseDoubleClick或MouseRightButtonDown等事件,它确实有效,但不是MouseDown,MouseUp或 MouseRightButtonDown )...看起来按钮自己消耗了事件,并且interaction.trigger从未见到过它。下面是我的XAML片段,我该如何解决这个问题?
<Button Content="DoStuff">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDown">
<i:InvokeCommandAction Command="{Binding StartCommand}" />
</i:EventTrigger>
<i:EventTrigger EventName="MouseUp">
<i:InvokeCommandAction Command="{Binding StopCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>