2019-11-29-WPF-开启-ScrollViewer-的触摸滚动
原文:2019-11-29-WPF-开启-ScrollViewer-的触摸滚动
title | author | date | CreateTime | categories |
---|---|---|---|---|
WPF 开启 ScrollViewer 的触摸滚动
|
lindexi
|
2019-11-29 10:21:47 +0800
|
2018-12-26 11:51:31 +0800
|
WPF
|
在 ScrollViewer 如果需要收到触摸消息,通过 Manipulation 触摸滚动,不能只是通过设置 IsManipulationEnabled 方法,还需要设置 PanningMode 才可以
那么如何知道滚动条的触摸事件是否触发,可以写一个类继承滚动条
public class StisvearpaHudalserevow : ScrollViewer
{
/// <inheritdoc />
protected override void OnManipulationDelta(ManipulationDeltaEventArgs e)
{
Debug.WriteLine("OnManipulationDelta");
base.OnManipulationDelta(e);
} /// <inheritdoc />
protected override void OnManipulationCompleted(ManipulationCompletedEventArgs e)
{
Debug.WriteLine("OnManipulationCompleted");
base.OnManipulationCompleted(e);
} /// <inheritdoc />
protected override void OnManipulationStarted(ManipulationStartedEventArgs e)
{
Debug.WriteLine("OnManipulationStarted");
base.OnManipulationStarted(e);
}
}
在界面添加这个类,如果有触摸输入就可以通过输出看到了,简单一个界面,可以看到默认的滚动条是不能滚动的
同时触摸的时候没有输出
尝试添加 IsManipulationEnabled 方法
<local:StisvearpaHudalserevow IsManipulationEnabled="True">
可以看到有输出但是就是不能滚动
在我博客 WPF 拖动滚动 告诉大家通过 PanningMode 的方法可以让滚动条滚动
只要在初始的过程设置了 PanningMode 因为在代码里面通过 InvalidateProperty 重新设置 IsManipulationEnabled 的值,所以只需要设置 PanningMode 就可以
/// <summary>
/// Method which sets IsManipulationEnabled
/// property based on the PanningMode
/// </summary>
private void OnPanningModeChanged()
{
PanningMode mode = PanningMode; // Call InvalidateProperty for IsManipulationEnabledProperty
// to reset previous SetCurrentValueInternal if any.
// Then call SetCurrentValueInternal to
// set the value of these properties if needed.
InvalidateProperty(IsManipulationEnabledProperty); if (mode != PanningMode.None)
{
SetCurrentValueInternal(IsManipulationEnabledProperty, BooleanBoxes.TrueBox);
}
}
但是如果在触摸的过程,出现了设置 IsManipulationEnabled 为 false 就会触发 OnManipulationCompleted 事件
protected override void OnManipulationStarted(ManipulationStartedEventArgs e)
{
Debug.WriteLine("OnManipulationStarted");
base.OnManipulationStarted(e); Task.Delay(TimeSpan.FromSeconds(3)).ContinueWith(_ => IsManipulationEnabled = false,
TaskScheduler.FromCurrentSynchronizationContext());
}
还可以通过设置 IsHitTestVisible = false
触发 OnManipulationCompleted 同时触发之后也没有触摸
2019-11-29-WPF-开启-ScrollViewer-的触摸滚动的更多相关文章
- 2019.11.29 Mysql的数据操作
为名为name的表增加数据(插入所有字段) insert into name values(1,‘张三’,‘男’,20); 为名为name的表增加数据(插入部分字段) insert into name ...
- 2019.11.29 SAP SMTP郵件服務器配置 發送端 QQ郵箱
今天群裏的小夥伴問了如何配置郵件的問題,隨自己在sap裏面配置了一個 1. RZ10配置參數 a) 参数配置前,先导入激活版本 执行完毕后返回 b) 输入参数文件DEFAU ...
- pycharm+anaconda在Mac上的配置方法 2019.11.29
内心os: 听人说,写blog是加分项,那他就不是浪费时间的事儿了呗 毕竟自己菜还是留下来东西来自己欣赏吧 Mac小电脑上进行python数据开发环境的配置 首先下载Anaconda,一个超好用的数据 ...
- Supervision meeting notes 2019/11/29
topic 分支: 1. subgraph/subsequence mining Wang Jin, routine behavior/ motif. Philippe Fournier Viger ...
- WPF的ScrollViewer鼠标的滚动
在C# 中,两个ScrollViewer嵌套在一起或者ScrollViewer里面嵌套一个ListBox.Listview(控件本身有scrollviewer)的时候,我们本想要的效果是鼠标滚动整个S ...
- WPF中ScrollViewer嵌套引发滚动失灵的Bug
事情起因 测试报告说存在滚动条不能拖动的情况,我们几个开发人员多次测试都未重现该问题.后面发现是操作系统的问题,在XP和部分Win7上会存在该问题.而在我们开发人员的机器上,包括Win7 SP1,Wi ...
- 解决WPF的ScrollViewer在使用触摸屏时,滑到尽头窗口抖动的情况
原文:解决WPF的ScrollViewer在使用触摸屏时,滑到尽头窗口抖动的情况 wpf的ScrollViewer在触摸条件下 默认在尽头时会有一个窗口一起被拖动的FeedBack,但对用户的交互很不 ...
- EOJ Monthly 2019.11 E. 数学题(莫比乌斯反演+杜教筛+拉格朗日插值)
传送门 题意: 统计\(k\)元组个数\((a_1,a_2,\cdots,a_n),1\leq a_i\leq n\)使得\(gcd(a_1,a_2,\cdots,a_k,n)=1\). 定义\(f( ...
- 通过解读 WPF 触摸源码,分析 WPF 插拔设备触摸失效的问题(问题篇)
在 .NET Framework 4.7 以前,WPF 程序的触摸处理是基于操作系统组件但又自成一套的,这其实也为其各种各样的触摸失效问题埋下了伏笔.再加上它出现得比较早,触摸失效问题也变得更加难以解 ...
随机推荐
- Google Analytics 学习笔记四 —— GA的Channels划分规则
一.流量的Source.Medium和Campaigns 1.Source Source或traffic source通常表示流量的来源,一般通过urm_source参数跟踪 在GA中,流量来源的名字 ...
- 起步:SpringBoot
pom.xml <parent> <groupId>org.springframework.boot</groupId> <artifactId>spr ...
- 关于SQLite数据库 字段 DateTime 类型
这两天刚接触SQLite 数据库 还没有太过于深入的了解 , 于是出现了一个问题 : 我在 C#中 ,使用SQLiteHelper 查询SQLite数据库数据时,报了这个错误: System.Form ...
- 使用 PXE+Kickstart 实现无人值守批量部署系统
一.废话两句 在云数据中心,一次几十台甚至几百台服务器上线,系统安装将变得非常繁琐,系统安装好了后还会涉及很多配置,如果一台台来安装的话工作量非常大.(虽然有加班费,开个玩笑)为了解决这个问题,我们需 ...
- linux 通过wol远程开机【转】
转自:http://yangbajing.blog.chinaunix.net/uid-10480699-id-5179860.html 今天发现个可以对linux服务器进行远程开机的软件-wakeo ...
- Python环境安装与基础语法(1)——计算机基础知识
Python安装 pip #包管理工具 pip install #安装包 pip list #查看包 IPython #增强的python shell,自动补全,自动缩进,支持shell,增加了很多函 ...
- 其他综合-CentOS 7 搭建模板机
CentOS 7 搭建模板机 [基于此文章的环境]点我快速打开文章 1.修改静态地址 ip a|awk -F '[ /]+' '$NF~/eth0/ {print $3}' cat >/etc/ ...
- clientHeight获取屏幕可视化高度
此时你设置后会发现屏幕的高度出现滚动条 那是因为body有8个外边距 设置margin:0就可以解决 watch可以区监听data中的数据,只要data中的数据发生变化 就可以执行watch中的函数了 ...
- VC 静态库与动态库(一)介绍
定义: 静态库与动态库都属于库,库从本质上来说就是种代码重用的方式. 把需要重复使用的公共代码抽离出来,生成库文件,外部程序只需包含库文件,调用相关接口即可 静态库与动态库区别: 静态库:需要库的.h ...
- springcloud注解解释
@SpringBootApplication是springboot启动类,包括三个注解,他们的作用分别是: @Configuration:表示将该类作用springboot配置文件类 @Enabl ...