I have a rectangle as an overlay and I want to modify its opacity by swiping up and down, like in the app Free Talking Alarm Clock. I figured out, that I have to deal with ManipulationStarted
and ManipulationDelta
events, but not sure which value to use. At this point I'm able to change the opacity by swiping, but changes only when the swipe is completed, and I want the opacity to change while I'm swiping. How do I do that?
Right now, I have this:
private Point initialpoint;
private double opacity;
private void rec_overlay_ManipulationStarted(object sender, ManipulationStartedRoutedEventArgs e)
{
initialpoint = e.Position;
}
private void rec_overlay_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
Point currentpoint = e.Position;
if (initialpoint.Y - currentpoint.Y < 0)
{
opacity += 0.1;
rec_overlay.Opacity = opacity;
System.Diagnostics.Debug.WriteLine("Swipe down");
}
else if(initialpoint.Y - currentpoint.Y > 0)
{
opacity -= 0.1;
rec_overlay.Opacity = opacity;
System.Diagnostics.Debug.WriteLine("Swipe up");
}
}