c# - 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 上调用命令。我已经尝试通过更改EventName
asLeftMouseDoubleClick
和LeftDoubleClick
但那些不起作用!在 Properties Inspector 的 Event 部分下 看起来LeftMouseDoubleClick 或 RighMouseDoubleClick有两个MouseDoubleClick
,但没有!PreviewMouseDoubleClick
有没有这样的事件?如果有,叫什么名字?如果没有,这种情况如何处理?
解决方案
您可以使用 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>
推荐阅读
- reactjs - 一个组件可以访问另一个不相关组件的视图模型吗?
- symfony - 带有固定字段的 Symfony 表单集合
- c# - 如何根据条件选择实体属性?
- java - 我在对齐元素时遇到问题(Java GUI / Swing);
- python - 使用python更改PowerPoint条形图中的值
- django - 在 Docker 容器中安装特定版本的 GDAL?
- twitter-bootstrap - 如何将 is-invalid 的 sass 样式引用到自定义类中?
- android-room - 如何查询Room中的条目数
- javascript - 更改边框颜色取决于值
- python - Jupyter:为什么第二个命令会阻止第一个命令工作?