Reputation: 35
In my WP8 app that controls Lego Mindstorms I have a Button
with UIElement.Hold Event
that triggers method runMotor()
When I release the Button
motor keeps on going but I would like it to stop. Method for stopping is stopMotor()
, I've already tried to assign it to KeyUp Event
but it doesn't work. Any solutions?
Upvotes: 2
Views: 131
Reputation: 89285
You can try to call stopMotor()
in ManupulationCompleted event. Note that ManipulationCompleted
event will get invoked after any gesture manipulation including Tap, Double Tap, Hold, and other gesture. Take that into account. If application scenario is still simple, checking if motor already running before calling stopMotor
in ManipulationCompleted
event handler maybe enough :
private void MyButton_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
if(isMotorRunning) stopMotor();
}
Upvotes: 2