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. kohana学习经验

    1.sql查询文件缓存使用 $tokens = DB::select('id', 'token') ->from('member') ->where('id', 'in', $users) ...

  2. Linux内核调试方法总结之栈帧

    栈帧 栈帧和指针可以说是C语言的精髓.栈帧是一种特殊的数据结构,在C语言函数调用时,栈帧用来保存当前函数的父一级函数的栈底指针,当前函数的局部变量以及被调用函数返回后下一条汇编指令的地址.如下图所示: ...

  3. dp基础大概 (8.6)

    一些前言: 据说动态规划会用排序,数据结构来进行乱搞优化操作 动态规划滴核心是个啥呢?状态表示和状态转移 设状态:哪些因素会影响到最终答案,就把哪些因素用数组的维度表示出来 要充分描述,也要简洁 举个 ...

  4. python-笔记(四)函数

    一.函数是什么? 函数一次来源于数学,但是编程中的[函数]的概念,与数学中的函数还是有很大的不同的,编程中的函数在英文中也有很多不同的叫法. 在Basic中叫做subroutine(子过程或子程序), ...

  5. Win32InputBox,C接口的,实现类似VB的InputBox的功能

    #ifndef __03022006__WIN32INPUTBOX__ #define __03022006__WIN32INPUTBOX__ /* This library is (c) Elias ...

  6. NanUI

    https://github.com/NetDimension/NanUI/wiki/%E4%B8%AD%E6%96%87%E8%AF%B4%E6%98%8E NanUI基于ChromiumFX项目进 ...

  7. GIt 添加到远程

    转载:https://www.liaoxuefeng.com/wiki/896043488029600/898732864121440 添加到远程 1.注册/登录 GitHub(https://git ...

  8. TensorFlow学习笔记10-卷积网络

    卷积网络 卷积神经网络(Convolutional Neural Network,CNN)专门处理具有类似网格结构的数据的神经网络.如: 时间序列数据(在时间轴上有规律地采样形成的一维网格): 图像数 ...

  9. 001/Docker入门(Mooc)

    docker官网:https://www.docker.com/ 1.什么是docker 2.Docker思想     ==> [1].集装箱:保证程序完整(不缺东西,如配置文件等). [2]. ...

  10. IDEA&GIT应用

    IDEA&GIT应用 一.IDEA整合GIT GIT教程:http://www.yiibai.com/git/git_pull.html File->Settings.. 1.从GIT上 ...