Search code examples
c#wpfmouseclick-event

In WPF / C#, how can I check if the center button is clicked or released?


In WPF / C#, there are events on MouseRightButtonDown and MouseLeftButtonDown, but what about the center mouse button?

Is the Center Mouse button down/up e.g. events in WPF forgotten?

How can I check if the center button is clicked or released?


Solution

  • Use the MouseDown/MouseUp event and check the MouseButtonEventArgs:

    private void control_MouseDown(object sender, MouseButtonEventArgs e)
    {
        if (e.ChangedButton == MouseButton.Middle)
        {
    
        }
    }