【问题标题】:WPF Mousebutton Command BindingWPF 鼠标按钮命令绑定
【发布时间】:2014-07-03 12:48:09
【问题描述】:

有没有一种方法可以将命令绑定到鼠标按钮,类似于绑定到键盘按钮的方式?

我正在使用键盘命令执行此操作:

 Application.Current.MainWindow.InputBindings.Add(new KeyBinding(this.NavigateForward, Key.Y, ModifierKeys.Control));

我想做这样的事情

 Application.Current.MainWindow.InputBindings.Add(new KeyBinding(this.NavigateForward, MouseButtons.XButton1)); //Not possible?

【问题讨论】:

  • 你可以为左/右/中间按钮单击/双击和滚轮单击但不能为 XButton
  • 例如,我将如何使用左/右?
  • 像这样使用MouseBindingInputBindings.Add(new MouseBinding(this.NavigateForward, new MouseGesture(MouseAction.LeftClick)))

标签: wpf mvvm mouse keyboard-shortcuts commandbinding


【解决方案1】:

我邀请您尝试 MvvMlight Toolkit 库,它以干净的方式公开了 EventToCommand 动作,任何动作都可能与命令相关。它还适用于 Sliverlight、Windows Phone 和 Windows Store 应用程序。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-16
    • 2016-01-14
    • 2015-06-07
    • 1970-01-01
    • 2013-10-09
    • 2017-01-31
    • 2015-12-09
    • 1970-01-01
    相关资源
    最近更新 更多