WPF RepeatButton MouseUp

2019-04-12 04:38发布

Is there a way to get the MouseUpevent on the repeatbutton to fire when the button is not pressed anymore? I am trying to use the MouseMove event to track the position of the mouse while the button is pressed, but neither MouseDown nor MouseUp fire an event for the left mouse button. Any ideas or advice as to what can be done? Thank you

2条回答
干净又极端
2楼-- · 2019-04-12 05:06

Without looking at code it is kind of tough, but an initial suggestion is to set handled to true in your mousemove method.

private void mouseMove(object sender, MouseEventArgs e)
{
//do everything you need to, then add this line at the end
e.Handled = true;
}

This should allow the previewMouseButton events to be fired.

查看更多
我想做一个坏孩纸
3楼-- · 2019-04-12 05:08

It appears that the repeat button is marking the event as handled internally. You can use the PreviewMouseLeftButtonUp tunneling event to catch the event before RepeatButton marks it as handled:

<RepeatButton x:Name="bob" PreviewMouseLeftButtonUp="bob_MouseUp" >
   Repeatinator!!
</RepeatButton>
查看更多
登录 后发表回答