WP7 捕捉屏幕的滑动方向(向上or向下)
<div id="cnblogs_post_body"> 之前都是用Touch.FrameReported来做触屏操作,但是后来发现有些细致的东西实现不了,比如TouchPoint的Action只能判断点击,移动和离开,对于是向上滑动还是向下滑动,就木有办法实现.经过自己的摸索,最后用ManipulationDelta来实现了该功能.
代码如下:
<div class="cnblogs_Highlighter">double firstY = 0.0; protected override void OnManipulationDelta(ManipulationDeltaEventArgs e) { if (firstY == 0.0) { firstY = e.CumulativeManipulation.Translation.Y; } else { double result = e.CumulativeManipulation.Translation.Y - firstY; if (result > 0) { this.Dispatcher.BeginInvoke(() => { MessageBox.Show("Move Down"); }); } else if (result < 0) { this.Dispatcher.BeginInvoke(() => { MessageBox.Show("Move Up"); }); } firstY = 0.0; } base.OnManipulationDelta(e); }
页:
[1]