首页 > 其他分享 >WPF 实现触摸滑动功能

WPF 实现触摸滑动功能

时间:2024-05-22 22:42:11浏览次数:14  
标签:ScrollViewer point 触摸 位置 mScrollViewer 滑动 WPF mIsTouch

自定义ScrollViewer的Touch事件--触摸上下移动ScrollViewer滚动到指定位置

 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 double mPointY;//触摸点的Y坐标 double mOffsetY;//滚动条当前位置 bool mIsTouch = false;//是否触摸 //触摸事件 private void mScrollViewer_TouchDown(object sender, TouchEventArgs e) {     mIsTouch = true;//正在触摸     mOffsetY = this.mScrollViewer.VerticalOffset;//获取ScrollViewer滚动条当前位置     TouchPoint point = e.GetTouchPoint(mScrollViewer);//获取相对于ScrollViewer的触摸点位置     mPointY = point.Position.Y;//触摸点的Y坐标 }   //触摸移动事件 private void mScrollViewer_TouchMove(object sender, TouchEventArgs e) {     if (mIsTouch == true)//如果正在触摸     {         TouchPoint point = e.GetTouchPoint(mScrollViewer);//获取相对于ScrollViewer的触摸点位置         double DiffOffset = point.Position.Y - mPointY;//计算相对位置         this.mScrollViewer.ScrollToVerticalOffset(mOffsetY - DiffOffset);//ScrollViewer滚动到指定位置     } }   //触摸结束事件 private void mScrollViewer_TouchUp(object sender, TouchEventArgs e) {     mIsTouch = false;//触摸结束 }

 

  分类: WPF

标签:ScrollViewer,point,触摸,位置,mScrollViewer,滑动,WPF,mIsTouch
From: https://www.cnblogs.com/webenh/p/18207292

相关文章

  • GeneralUpdate .Net5 WPF、Winfrom、控制台应用自动更新组件
    https://www.bilibili.com/video/BV1aX4y137dd/?vd_source=43d3e66cc2ad46bac54dfb0c6a3a0a23    GeneralUpdate教程2022.4.23 https://www.bilibili.com/video/BV1FT4y1Y7hV/?vd_source=43d3e66cc2ad46bac54dfb0c6a3a0a23   https://mp.weixin.qq.com/s/pR......
  • 基于WPF+Sqlite开发抽奖软件【内附源码】
    在很早之前,就想过开发一款抽奖软件,却一直没有实际去做,最近经过一段时间的准备,终于开发出了一款基于WPF+Sqlite版的抽奖软件,包括客户端和管理端。本项目主要是为了熟悉WPF开发流程,仅供学习分享使用,如有不足之处,还请指正。 涉及知识点 抽奖软件是包括客户端和管理端,在抽奖软件......
  • WPF ListBox thumbnails and image mvvm behavior CallMethodAction
    <Windowx:Class="WpfApp108.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft......
  • Serilog日志输出到WPF UI控件
    使用到日志接收器的接口 ILogEventSinkWPF+Prsim+Serilog详细介绍链接 https://github.com/serilog/serilog/wiki/Developing-a-sink   publicinterfaceILogEventSinkWrite:ILogEventSink{LogEventGetLogMessage();}publicclassLogEventSink:I......
  • 界面组件DevExpress WPF v23.2新版亮点:富文本编辑器、电子表格组件升级
    DevExpressWPF拥有120+个控件和库,将帮助您交付满足甚至超出企业需求的高性能业务应用程序。通过DevExpressWPF能创建有着强大互动功能的XAML基础应用程序,这些应用程序专注于当代客户的需求和构建未来新一代支持触摸的解决方案。DevExpressWPF控件日前正式发布了近期的一个重大......
  • vue路由切换滑动效果
    1.增加页面路由{path:'/feedbackList',name:'feedbackList',component:()=>import('../views/feedbackList/index'),meta:{title:"反馈列表",index:1}},{path:'/feedback......
  • WPF OpenCVSharp4
    usingOpenCvSharp;usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Windows.Data;usingSystem.Windows.Documents;usingSy......
  • WPF Image ZoomIn ZoomOut via MouseWheel
    //xaml<Windowx:Class="WpfApp104.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.mi......
  • dotnet X11 设置窗口鼠标触摸命中穿透
    本文记录如何在X11应用里面,使用XShapeCombineRegion方法配置一个X11窗口支持和Win32窗口一样的命中测试穿透功能,即对应Win32的WS_EX_TRANSPARENT的鼠标、触摸等的点击等动作的穿透功能,可以实现在窗口中挖空一块范围直接穿透到后面的窗口在X11窗口中,想要实现让窗口......
  • 高抗干扰触摸芯片VK36N系列1/2/3/4/5/6/7/8/9/10按键/通道适用于家电/玩具【FAE技术支
     概述.VK36N1D具有1个触摸按键,可用来检测外部触摸按键上人手的触摸动作。该芯片具有较高的集成度,仅需极少的外部组件便可实现触摸按键的检测。提供了1个1对1输出脚,可通过IO脚选择上电输出电平,有直接输出和锁存输出2个型号可选。芯片内部采用特殊的集成电路,具有高电源电压......