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?
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?
Use the MouseDown/MouseUp event and check the MouseButtonEventArgs:
private void control_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Middle)
{
}
}
Use the MouseDown
and MouseUp
events:
You should use the MouseDown event and check the MiddleButton state in the event arguments.
you can handle MouseDown event and in event handler you can check which Mouse Button was pressed by using
if(e.ChangedButton == System.Windows.Input.MouseButton.Middle)
{
.....
}
I do not 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 MiddleButton state like so,
void Window1_MouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show(e.MiddleButton.ToString());
}