我试图找出一种方法来简单地让用户控件具有与“按钮”相同的功能,但不会阻止“MouseLeftButtonDown”和“MouseLeftButtonUp”冒泡。
对于我的特定应用程序,我无法使用任何技巧背后的代码来解决它 - 我绑定到 MVVM 模式以将命令转发给其他进程。
我发现了很多关于这个话题的讨论,但没有一个指向一个简单的解决方案。
要清楚一个不工作的例子:
<Button Width="30" Height="20" Content="+">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<i:InvokeCommandAction Command="{Binding MoveAxisFwdCommand}" CommandParameter="true" />
</i:EventTrigger>
<i:EventTrigger EventName="MouseLeftButtonUp">
<i:InvokeCommandAction Command="{Binding MoveAxisFwdCommand}" CommandParameter="false" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>