C# 执行ctrl+;班次+;mvvm中按钮上的鼠标悬停

C# 执行ctrl+;班次+;mvvm中按钮上的鼠标悬停,c#,wpf,mvvm,prism-6,C#,Wpf,Mvvm,Prism 6,我试图在wpf、mvvm中的一个按钮上实现ctrl+shift+mouseover。 我正在做一些类似于: <Button.InputBindings> <KeyBinding Gesture="Ctrl+Shift" Command="{Binding KeyCommand}" CommandParameter="{Binding Mode=OneWay, RelativeSource={RelativeSource Self}}" /> </Butt

我试图在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
MouseLeftButtonDown
事件,并检查在引发事件时是否按下了Ctrl键和Shift键,例如:

private void OnMouseEnter(object sender, MouseEventArgs e)
{
    if ((Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
        && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
    {
        TheCommand.Execute(null);
    }
}

你想要实现什么?在Ctrl+Shift+MouseOver的情况下会发生什么?按下按钮时是否不需要MouseOver?没有鼠标盖你怎么能按这个按钮?“回车”键?有什么区别?写一个检查鼠标事件键修改器的行为。我在Ctrl+Shift+LeftClick上绑定了不同的命令,在Ctrl+Shift+MouseOver上绑定了不同的命令。这两个命令是分开的,用于不同的目的。我需要以纯MVVM的方式实现。这就是为什么我建议您应该创建一个附加的行为。这是纯MVVM。那么你的观点是什么?如果你不知道附加行为是什么,你应该点击我提供的链接。听起来您还想更多地了解MVVM……使用输入绑定和交互触发器无法解决这个问题。
private void OnMouseEnter(object sender, MouseEventArgs e)
{
    if ((Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
        && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
    {
        TheCommand.Execute(null);
    }
}