WPF InputBinding Ctrl + MWheelUp/Down可能吗? [英] WPF InputBinding Ctrl+MWheelUp/Down Possible?
问题描述
是否可以将Command绑定到Ctrl+MWheelUp/Down
?您知道在浏览器中是否可以执行相同的操作以增加/减小字体大小?我想在WPF中复制这种效果.可能的?我正在查看 InputBinding > 鼠标绑定和解决方案
好,我在ShellView : Window
this.KeyDown += (s, e) =>
{
_leftCtrlPressed = (e.Key == Key.LeftCtrl) ? true : false;
};
this.MouseWheel += (s, e) =>
{
if (_leftCtrlPressed) {
if (e.Delta > 0)
_vm.Options.FontSize += 1;
else if (e.Delta < 0)
_vm.Options.FontSize -= 1;
}
};
我认为行为"方法将使事情更清洁,更可重用,但是我并没有真正理解它.如果有人在这里用简单的方式解释它,那会很棒吗?
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
Ok, I did something like this in my ShellView : Window
this.KeyDown += (s, e) =>
{
_leftCtrlPressed = (e.Key == Key.LeftCtrl) ? true : false;
};
this.MouseWheel += (s, e) =>
{
if (_leftCtrlPressed) {
if (e.Delta > 0)
_vm.Options.FontSize += 1;
else if (e.Delta < 0)
_vm.Options.FontSize -= 1;
}
};
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?
这篇关于WPF InputBinding Ctrl + MWheelUp/Down可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!