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

There are events in MouseFightButtonDown and MouseLeftButtonDown in WPF / C #, but what about the center mouse button?

Is the Center mouse button pressed / up, for example. events in WPF forgot?

How to check if the center button is pressed or released?

+4
source share
4 answers

Use the MouseDown / MouseUp event and check MouseButtonEventArgs:

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

Use MouseDown and MouseUp events:

You should use the MouseDown event and check the status of MiddleButton in the event arguments.

0
source

you can handle the MouseDown event, and in the event handler you can check which mouse button is clicked using

 if(e.ChangedButton == System.Windows.Input.MouseButton.Middle) { ..... } 
0
source

I don’t think there is a direct event handler defined for Up or Down events. The only thing we could do is handle the MouseDown event and check the status of MiddleButton so that

 void Window1_MouseDown(object sender, MouseButtonEventArgs e) { MessageBox.Show(e.MiddleButton.ToString()); } 
0
source

All Articles