WPF: Detect Ctrl+MWheelUp/Down
I can bind to Ctrl+C or Ctrl+LeftClick, but how can I bind to mouse/scroll wheel actions?
I am trying to do something like increase/decrease f开发者_如何学Cont size, like in a browser.
I want to set Ctrl+MWheelUp to the increase font size
In constructor add event to PreviewMouseWheel
PreviewMouseWheel += Window_PreviewMouseWheel;
And then in the handler detect the key
private void Window_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (Keyboard.Modifiers != ModifierKeys.Control)
return;
if (e.Delta > 0)
ZoomIn();
else if (e.Delta < 0)
ZoomOut();
}
精彩评论