Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I handle the mouse wheel click event in 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?

EDIT: 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");
        }
    }
like image 610
ScottG Avatar asked Feb 05 '09 19:02

ScottG


1 Answers

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

like image 84
Jobi Joy Avatar answered Oct 22 '22 18:10

Jobi Joy