首页 > 解决方案 > Left MouseDoubleClick 事件的名称是什么?

问题描述

我有一个EventTrigger

<i:Interaction.Triggers>
    <i:EventTrigger EventName="MouseDoubleClick">
        <i:InvokeCommandAction Command="{Binding Modify}" 
                            CommandParameter="{Binding SelectedItem, ElementName=lv}"/>
    </i:EventTrigger>
</i:Interaction.Triggers>

它调用 on 的命令MouseDoubleClick,不管它是左还是右!我希望它仅在 Left MouseDoubleClick 上调用命令。我已经尝试通过更改EventNameasLeftMouseDoubleClickLeftDoubleClick但那些不起作用!在 Properties Inspector 的 Event 部分下 看起来LeftMouseDoubleClick 或 RighMouseDoubleClick有两个MouseDoubleClick,但没有!PreviewMouseDoubleClick

有没有这样的事件?如果有,叫什么名字?如果没有,这种情况如何处理?

标签: c#wpfeventtrigger

解决方案


您可以使用 InputBindings 来处理这个问题。左双击和右双击有特定的事件。

<Window.InputBindings>
    <MouseBinding MouseAction="LeftDoubleClick"
                  Command="{Binding MessageCommand}"
                  CommandParameter="Left Double Click"/>
    <MouseBinding MouseAction="MiddleDoubleClick"
                  Command="{Binding MessageCommand}"
                  CommandParameter="Middle Double Click"/>
    <MouseBinding MouseAction="RightDoubleClick"
                  Command="{Binding MessageCommand}"
                  CommandParameter="Right Double Click"/>
    <MouseBinding MouseAction="WheelClick"
                  Command="{Binding MessageCommand}"
                  CommandParameter="Wheel Click"/>
</Window.InputBindings>

这在本文中有详细讨论


推荐阅读