WPF 输入绑定 Ctrl+MWheelUp/Down 可能吗?
有没有办法可以将命令绑定到 Ctrl+MheelUp/Down
?您知道在浏览器中,您可以执行相同的操作来增大/减小字体大小吗?我想在 WPF 中复制这种效果。可能的?我正在查看 InputBinding > MouseBindings 和 MouseAction 似乎不支持鼠标卷轴。
* 我好像发过类似的问题,但是找不到了
Is there a way I can bind a Command to Ctrl+MWheelUp/Down
? U know in a browser, you can do the same to increase/decrease font size? I want to replicate that effect in WPF. Possible? I was looking at InputBinding > MouseBindings and MouseAction does not seem to support Mouse Scrolls.
* I seem to have posted a similar question, but can't find it anymore
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
完成:
可以使用非常简单的自定义 MouseGesture:在 xaml 中
It can be done using very simple custom MouseGesture:
in the xaml:
好吧,我在我的
ShellView : Window
中做了类似的事情,我认为 Behaviour 方法会让事情变得更干净、更可重用,但我并没有真正明白。如果有人在这里用简单的方式解释一下那就太好了?
Ok, I did something like this in my
ShellView : Window
I think the Behaviour method will make things cleaner and more reusable, but I didn't really get it. It'll will be great if someone explained it in a simple way here?
窗口有 MouseWheel 事件。您可以执行一些命令绑定魔术,然后将其绑定到 DataContext 属性。查看这篇 SO 文章以获取提示:在文本框 MVVM 内按下按键。另请查看这篇文章:http://code.msdn.microsoft.com/eventbehaviourfactor
Window has the MouseWheel event. You can do some command binding magic which you can then bind to a DataContext property. Check out this SO article for hints: Key press inside of textbox MVVM. Also take a look at this article: http://code.msdn.microsoft.com/eventbehaviourfactor
我只是使用 Interaction.Triggers 绑定命令。
您需要在 XAML 中引用表达式交互命名空间。
然后在相关命令中。
如果 Delta 上升,则鼠标向上滚动;如果 Delta 下降,则鼠标向下滚动。我在一个应用程序中使用此功能,其中可滚动内容中会发生滚动,但当按下任一 Ctrl 键时,应用程序实际上会缩放。
I simply bind the command using Interaction.Triggers.
You'll need to reference the expression interactivity namespace in XAML.
Then in the associated command.
If Delta is rising the mouse is scrolling Up, falling it is scrolling Down. I use this in an application where Scrolling will occur in scroll-able content but when either of the Ctrl keys are down, the application actually zooms.