title author date CreateTime categories
UWP how to get the touch width
lindexi
2018-11-15 18:49:12 +0800
2018-11-06 09:25:23 +0800
UWP

The touch width can help us to make a gorgeous application. This article tells you how to get the touch width from the PointEvent in UWP.

Opening the VisualStudio and create an empty UWP application.

We should open the MainPage.xaml and add the background in the Grid to make the Grid can get the PointMove event.

    <Grid Background="Transparent">

    </Grid>

Then we can open the MainPage.xaml.cs to write the code to get the PointerMove event.

        public MainPage()
{
InitializeComponent(); Content.PointerMoved += MainPage_PointerMoved;
} private void MainPage_PointerMoved(object sender, PointerRoutedEventArgs e)
{ }

We can use GetCurrentPoint to get the PointerPoint.

        private void MainPage_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var point = e.GetCurrentPoint(this);
}

And we can find the ContactRect in Properties. We can get the touch width from ContactRect.

        private void MainPage_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var point = e.GetCurrentPoint(this);
Rect rect = point.Properties.ContactRect;
}

To get the touch width.

        private void MainPage_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var point = e.GetCurrentPoint(this);
Rect rect = point.Properties.ContactRect;
Debug.WriteLine($"Touch rect width={rect.Width},height={rect.Height}");
}

We also can use ContactRectRaw in Properties.

        private void MainPage_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var point = e.GetCurrentPoint(this);
Rect rect = point.Properties.ContactRect;
Debug.WriteLine($"Touch rect width={rect.Width},height={rect.Height}");
rect = point.Properties.ContactRectRaw;
Debug.WriteLine($"Touch raw rect width={rect.Width},height={rect.Height}");
}

Try to run the code and touch the application and you can watch the output windows that prints the touch width.

2018-11-15-UWP-how-to-get-the-touch-width的更多相关文章

  1. 2018.11.15 Nginx服务器的使用

    Nginx简单教程 1.什么是Nginx? Nginx(engine x)是一款轻量级的Web服务器.反向代理服务器及电子邮件(IMAP/POP3)代理服务器 什么是反向代理服务器? 反向代理方式是指 ...

  2. 2018.11.15 RF antenna impedance-matching

    We have studied the impedance-matching of RF transmission line between the antenna and the RX / TX m ...

  3. OI生涯回忆录 2018.11.12~2019.4.15

    上一篇:OI生涯回忆录 2017.9.10~2018.11.11 一次逆风而行的成功,是什么都无法代替的 ………… 历经艰难 我还在走着 一 NOIP之后,全机房开始了省选知识的自学. 动态DP,LC ...

  4. Sprint1(第二天11.15)

    Sprint1(第二天11.15) Sprint1第一阶段 1.类名:软件工程-第一阶段 2.时间:11.14-11.23 3.选题内容:web版-餐厅到店点餐系统 4.团队博客地址: http:// ...

  5. Tencent Cloud Developers Conference(2018.12.15)

    时间:2018.12.15地点:北京朝阳悠唐皇冠假日酒店

  6. China Intelligent Office Summit(2018.11.21)

    时间:2018.11.21地点:中关村软件园国际会议中心

  7. International Programming Retreat Day(2018.11.17)

    时间:2018.11.17地点:北京国华投资大厦

  8. Intel Artificial Intelligence Conference(2018.11.14)

    时间:2018.11.14地点:北京国贸大酒店

  9. Lean Data Innovation Sharing Salon(2018.09.15)

    时间:2018.09.15地点:北京国华投资大厦

  10. Notes of Daily Scrum Meeting(11.15)

    Notes of Daily Scrum Meeting(11.15) 今天周六我们的主要工作是把这周落下的一些工作补回来,这是写程序的最后阶段,准备进入测试阶段了,所以之前的工作 要补齐,今天大家的 ...

随机推荐

  1. 数位dp浅谈(hdu3555)

    数位dp简介: 数位dp常用于求区间内某些特殊(常关于数字各个数位上的值)数字(比如要求数字含62,49): 常用解法: 数位dp常用记忆化搜索或递推来实现: 由于记忆化搜索比较好写再加上博主比较蒟, ...

  2. Sonys TRC save data plolicy

    帖子地址:https://forums.unrealengine.com/showthread.php?130820-Sonys-TRC-save-data-plolicy we had severa ...

  3. ES6 嵌套数组进行解构

    let [foo, [[bar], baz]] = [1, [[2], 3]]; foo // 1 bar // 2 baz // 3 let [ , , third] = ["foo&qu ...

  4. 转:KVM使用NAT联网并为VM配置iptables端口转发,kvmiptables

    转载地址:https://www.ilanni.com/?p=7016 在前面的文章中,我们介绍KVM的虚拟机(以下简称VM)都是通过桥接方式进行联网的. 本篇文章我们来介绍KVM的VM通过NAT方式 ...

  5. Vue音乐播放器(三):项目目录介绍,以及图标字体、公共样式等资源准备

    我们所有的开发都是基于修改src下面的目录 里面的文件去做开发即可 stylus的使用是需要下载stylus-loader的包的 渲染效果 配置修改eslintrc.js 配置了webpack.bas ...

  6. Socket 网络编程实践经验

    目录 目录 相关文章 Socket 与 HTTP 的区别 生产实践考虑 网络断开重连问题 Heartbeat 心跳机制 使用非阻塞模式下的 select 函数进行 Socket 连接检查 会话过期问题 ...

  7. 多线程threading初识,线程等待

    1.线程是程序里面最小的执行单元. 2.进程是资源的集合. 线程是包含在进程里面的,一个进程可以有多个线程,但只要要有一个线程. 一.多线程,就是N个线程一起干活: 1.传统方式,串行,循环5次需要1 ...

  8. dict用法

    1 dict.items() https://www.runoob.com/python3/python3-att-dictionary-items.html 2 setdefault的用法 注意se ...

  9. Jmeter之CSV Data Set Config

    在很多情况下,需要针对测试数据做参数化操作,Jmeter提供了很好用的CSV Data Set Config插件. 一.界面显示 二.界面说明 1.名称:标识,建议设置为该组件是提供什么功能 2.注释 ...

  10. idea的类头注释和方法注释的编辑

    一:配置类头注释 1:点击file,点击settings 2:点击editor,选择 file and code template ,然后看右侧部分点击include,之后选中File Header ...