【发布时间】:2018-07-18 06:38:53
【问题描述】:
我正在尝试在 wpf、mvvm 中的按钮上实现 ctrl+shift+mouseover。 我正在做类似的事情:
<Button.InputBindings>
<KeyBinding Gesture="Ctrl+Shift" Command="{Binding KeyCommand}"
CommandParameter="{Binding Mode=OneWay, RelativeSource={RelativeSource Self}}"
/>
</Button.InputBindings>
或类似:
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<i:InvokeCommandAction Command="{Binding MouseOverCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
由于鼠标手势不支持“MouseEnter”事件,我无法获得所需的行为。 我试图以如下方式实现:
Step 1.- Through keybinding setting a variable in the viewmodel.
Step 2.- Accessing that variable's value on MouseEnter and do whatever in the command.
感谢任何帮助。
【问题讨论】:
-
你想达到什么目的?如果出现 Ctrl+Shift+MouseOver 应该怎么办?
-
MouseOver 不需要按下按钮吗?你怎么能在没有鼠标悬停的情况下按下按钮? “回车键?会有什么区别?
-
写一个行为来检查你的鼠标事件键修饰符。
-
我在 Ctrl+Shift+LeftClick 上绑定了一个不同的命令,在 Ctrl+Shift+MouseOver 上绑定了一个不同的命令。这两个命令是独立的,用于不同的目的。