备份下 原文 https://www.cnblogs.com/webenh/p/18207292
<ScrollViewer x:Name="scroll" TouchDown="mScrollViewer_TouchDown" TouchMove="mScrollViewer_TouchMove" TouchUp="mScrollViewer_TouchUp"> </ScrollViewer>
double mPointY;//触摸点的Y坐标 double mOffsetY;//滚动条当前位置 bool mIsTouch = false;//是否触摸 //触摸事件 private void mScrollViewer_TouchDown(object sender, TouchEventArgs e) { mIsTouch = true;//正在触摸 mOffsetY = this.scroll.VerticalOffset;//获取ScrollViewer滚动条当前位置 TouchPoint point = e.GetTouchPoint(scroll);//获取相对于ScrollViewer的触摸点位置 mPointY = point.Position.Y;//触摸点的Y坐标 } //触摸移动事件 private void mScrollViewer_TouchMove(object sender, TouchEventArgs e) { if (mIsTouch == true)//如果正在触摸 { TouchPoint point = e.GetTouchPoint(scroll);//获取相对于ScrollViewer的触摸点位置 double DiffOffset = point.Position.Y - mPointY;//计算相对位置 this.scroll.ScrollToVerticalOffset(mOffsetY - DiffOffset);//ScrollViewer滚动到指定位置 } } //触摸结束事件 private void mScrollViewer_TouchUp(object sender, TouchEventArgs e) { mIsTouch = false;//触摸结束 }
标签:控件,ScrollViewer,point,触摸,mPointY,WPF,scroll,mIsTouch From: https://www.cnblogs.com/EndlessLife/p/18344989