如何处理WPF中的鼠标滚轮点击事件? [英] How can I handle the mouse wheel click event in WPF?

查看:1681
本文介绍了如何处理WPF中的鼠标滚轮点击事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当鼠标滚轮被点击时,我想在标签控件中关闭一个标签页。如何在WPF中捕获此事件?

I want to close a tab in my tab control when the mouse wheel is clicked. How can I capture this event in WPF?

编辑:
以下是代码:

Here's the code:

private void tabMain_MouseDown(object sender, MouseButtonEventArgs e)
    {
        if(e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed)
        {
            MessageBox.Show("Middle button clicked");
        }
    }


推荐答案

Mousewheel实际上是MiddleButton,所以Wheel点击MouseDown事件的条件是 ChangedButton == Middle&& ButtonState ==已按

Mousewheel is actually the MiddleButton, So the condition for Wheel click on a MouseDown event is ChangedButton == Middle && ButtonState == Pressed

这篇关于如何处理WPF中的鼠标滚轮点击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆