在控制 Lego Mindstorms 的 WP8 应用程序中,我有一个带有 UIElement.Hold Event
的 Button
,当我释放时,它会触发方法 runMotor()
Button
电机继续运转,但我希望它停止。停止的方法是 stopMotor()
,我已经尝试将其分配给 KeyUp Event
但它不起作用。有什么解决办法吗?
最佳答案
您可以尝试在ManupulationCompleted中调用stopMotor()
事件。请注意,ManipulationCompleted
事件将在任何手势操作(包括 Tap, Double Tap, Hold, and other gesture)之后被调用。 。考虑到这一点。如果应用场景仍然简单,在 ManipulationCompleted
事件处理程序中调用 stopMotor
之前检查电机是否已经运行就足够了:
private void MyButton_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
if(isMotorRunning) stopMotor();
}
关于c# - 释放按钮时停止 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21394609/