2018-12-26-WPF-开启-ScrollViewer-的触摸滚动
| title | author | date | CreateTime | categories |
|---|---|---|---|---|
|
WPF 开启 ScrollViewer 的触摸滚动
|
lindexi
|
2018-12-26 14:24:26 +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 同时触发之后也没有触摸
2018-12-26-WPF-开启-ScrollViewer-的触摸滚动的更多相关文章
- OPPO Developers Conference(2018.12.26)
时间:2018.12.26地点:北京国家会议中心
- 微信小程序 - 接口更新记录以及解决方案(2018/12/26)
2018/8/17 - 背景音频需要在app.json添加requireBackGroundModes 2018/9/12 - 微信更改获取用户信息接口/获取位置等接口 - button 2018/1 ...
- 2018.12.26 Mac下的Eclipse在编辑Spring配置文件xml时自动提示类class包名配置
1.先查看下自己的Eclipse是什么版本,步骤如下: 2.选择Install New Software 3.输入网址 http://dist.springsource.com/release/TOO ...
- 2018.12.26 考试(哈希,二分,状压dp)
T1 传送门 解题思路 发现有一个限制是每个字母都必须相等,那么就可以转化成首尾的差值相等,然后就可以求出\(k-1\)位的差值\(hash\)一下.\(k\)为字符集大小,时间复杂度为\(O(nk) ...
- WPF的ScrollViewer鼠标的滚动
在C# 中,两个ScrollViewer嵌套在一起或者ScrollViewer里面嵌套一个ListBox.Listview(控件本身有scrollviewer)的时候,我们本想要的效果是鼠标滚动整个S ...
- WPF中ScrollViewer嵌套引发滚动失灵的Bug
事情起因 测试报告说存在滚动条不能拖动的情况,我们几个开发人员多次测试都未重现该问题.后面发现是操作系统的问题,在XP和部分Win7上会存在该问题.而在我们开发人员的机器上,包括Win7 SP1,Wi ...
- 2019-11-29-WPF-开启-ScrollViewer-的触摸滚动
原文:2019-11-29-WPF-开启-ScrollViewer-的触摸滚动 title author date CreateTime categories WPF 开启 ScrollViewer ...
- 解决WPF的ScrollViewer在使用触摸屏时,滑到尽头窗口抖动的情况
原文:解决WPF的ScrollViewer在使用触摸屏时,滑到尽头窗口抖动的情况 wpf的ScrollViewer在触摸条件下 默认在尽头时会有一个窗口一起被拖动的FeedBack,但对用户的交互很不 ...
- 通过解读 WPF 触摸源码,分析 WPF 插拔设备触摸失效的问题(问题篇)
在 .NET Framework 4.7 以前,WPF 程序的触摸处理是基于操作系统组件但又自成一套的,这其实也为其各种各样的触摸失效问题埋下了伏笔.再加上它出现得比较早,触摸失效问题也变得更加难以解 ...
- WPF实现ScrollViewer滚动到指定控件处
在前端 UI 开发中,有时,我们会遇到这样的需求:在一个 ScrollViewer 中有很多内容,而我们需要实现在执行某个操作后能够定位到其中指定的控件处:这很像在 HTML 页面中点击一个链接后定位 ...
随机推荐
- linux下firefox用css配置把网页设置成黑白
网址输入 about:config 忽略警告 toolkit.legacyUserProfileCustomizations.stylesheets设置为true 在 /home/user/.mozi ...
- 整合mybatis-spring需要的maven依赖配置
创建maven项目,导入相关jar包 junit 1 <dependency> 2 <groupId>junit</groupId> 3 <artifactI ...
- 5 CSS伪类选择器
5 伪类选择器 anchor伪类:专用于控制链接的显示效果 More Actions:link a:link 选择所有未被访问的链接. :visited a:visited 选择所有已被访问的链接. ...
- #计数#CF10C Digital Root
题目 定义\(d(x)\)为\(x\)的数位和嵌套,直至\(0\leq d(x)<10\) 询问在\([1\sim n]\)中有多少个三元组\((a,b,c)\)满足 \[ab\neq c,d( ...
- #树状数组,离散#C 波动序列
分析 设\(dp[i][j][0/1/2/3]\)表示前\(i\)个位置当前选的数为\(j\), 且选择的是第一行/第二行/第三行不下降/第三行不上升, 状态转移方程显然,用线段树或者树状数组维护一下 ...
- flutter系列之:按比例缩放的AspectRatio和FractionallySizedBox
目录 简介 AspectRatio FractionallySizedBox 总结 简介 我们在构建UI的时候,为了适应不同的屏幕大小,通常需要进行一些自适应的配置,而最常见的自适应就是根据某个宽度或 ...
- OpenHarmony使用ArkUI Inspector分析布局
本文转载自<#2023 盲盒+码 # OpenHarmony使用ArkUI Inspector分析布局>,作者:zhushangyuan_ OpenHarmony使用ArkUI Ins ...
- 深入理解 C++ 右值引用和移动语义:全面解析
C++11引入了右值引用,它也是C++11最重要的新特性之一.原因在于它解决了C++的一大历史遗留问题,即消除了很多场景下的不必要的额外开销.即使你的代码中并不直接使用右值引用,也可以通过标准库,间接 ...
- 你知道什么叫做API、SDK吗?
链接:https://www.zhihu.com/question/21691705/answer/770586138 API.SDK是什么......... 讲个小故事: 研发人员A开发了软件A,研 ...
- selenium 关闭浏览--- close 与 quit 的区别
selenium 关闭浏览器,有两种方式 close quit 既然都是关闭浏览器,为什么要写两种方式? 区别 close: close只是关闭浏览器,但是不会退出 webdriver quit: q ...