单击鼠标滚轮时,我想关闭选项卡控件中的选项卡。如何在WPF中捕获此事件?
编辑: 这是代码:
private void tabMain_MouseDown(object sender, MouseButtonEventArgs e)
{
if(e.ChangedButton == MouseButton.Middle && e.ButtonState == MouseButtonState.Pressed)
{
MessageBox.Show("Middle button clicked");
}
}
答案 0 :(得分:10)
Mousewheel实际上是MiddleButton,因此Wheel点击MouseDown事件的条件是 ChangedButton == Middle&& ButtonState ==按
答案 1 :(得分:3)
更简单的解决方案
if(e.MiddleButton){MessageBox.Show("中键点击"); }