今天运行在windows平板上的程序,有个功能是弹出子窗体,点弹出窗体的关闭按钮,要点好几次才能触发。网上找了找,也有人与我类似的情形。

解决方法如下:

public static void DisableWPFTabletSupport()
{
// Get a collection of the tablet devices for this window.
TabletDeviceCollection devices = System.Windows.Input.Tablet.TabletDevices; if (devices.Count > )
{
// Get the Type of InputManager.
Type inputManagerType = typeof(System.Windows.Input.InputManager); // Call the StylusLogic method on the InputManager.Current instance.
object stylusLogic = inputManagerType.InvokeMember("StylusLogic",
BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
null, InputManager.Current, null); if (stylusLogic != null)
{
// Get the type of the device class.
Type devicesType = devices.GetType(); // Loop until there are no more devices to remove.
int count = devices.Count + ; while (devices.Count > )
{
// Remove the first tablet device in the devices collection.
devicesType.InvokeMember("HandleTabletRemoved", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic, null, devices, new object[] { (uint) }); count--; if (devices.Count != count)
{
throw new Win32Exception("Unable to remove real-time stylus support.");
}
}
}
}
}

这种方式,是禁用掉wpf对平板功能的支持,我试了下,确实点击关闭按钮很容易触发。但是这个方法会把滑动效果禁掉。比如滑动列表。这样用户体验会不好。

后来想了想,触摸屏点击肯定会触发TouchDown事件的。

   private void Button_TouchDown(object sender, TouchEventArgs e)
{
this.Close();
}

很简单就解决了。

WPF 平板上按钮点击不触发,鼠标点击触发的两种解决方法的更多相关文章

  1. 史上最全的CSS hack方式一览 jQuery 图片轮播的代码分离 JQuery中的动画 C#中Trim()、TrimStart()、TrimEnd()的用法 marquee 标签的使用详情 js鼠标事件 js添加遮罩层 页面上通过地址栏传值时出现乱码的两种解决方法 ref和out的区别在c#中 总结

    史上最全的CSS hack方式一览 2013年09月28日 15:57:08 阅读数:175473 做前端多年,虽然不是经常需要hack,但是我们经常会遇到各浏览器表现不一致的情况.基于此,某些情况我 ...

  2. JQ trigger函数无法触发a标签的两种解决方法

    起因:点击icon图标后要触发a标签的链接转跳动作,但是用 JQ 的 $('#a').trigger('click') 居然不起作用,遂百度之,总结两种方法如下: (原因:JQ 的 trigger() ...

  3. 在IIS上部署.net core的webapi项目 以及502.5错误的两种解决方法

    首先要在服务器上面安装.net core https://github.com/dotnet/core/tree/master/release-notes/download-archives 这里面有 ...

  4. eclipse上一次没有正确关闭,导致启动的时候卡死错误解决方法

    关于 eclipse启动卡死的问题(eclipse上一次没有正确关闭,导致启动的时候卡死错误解决方法),自己常用的解决方法: 方案一(推荐使用,如果没有这个文件,就使用方案二): 到<works ...

  5. WPF中C#代码触发鼠标点击事件

    1.如下代码; <Button x:Name="btnTest" Click="btnTest_Click"> <Button.Trigger ...

  6. swift项目实战--微博的未登录界面的实现,和监听未登录界面两个按钮的两种实现方法

    1.未登录界面的实现 微博项目中,用户不登录的话,显示的是未登录的界面.项目中TabBarVC的子控制器都是tableViewVC,所以抽取了父类,让父类判断用户是否登录,决定显示什么样的界面.loa ...

  7. Visual Studio写的项目在 IIS 服务器上运行的两种简单方法

    首先需要PC上开启了IIS服务,相关方法网上很多,也很简单 第一种:直接在项目中操作 1.创建一个项目,然后右击选中项目,右击,单击属性,打开项目属性标签页面 如图,选择Web标签,在服务器栏目中选中 ...

  8. TQ2440学习笔记——Linux上I2C驱动的两种实现方法(1)

    作者:彭东林 邮箱:pengdonglin137@163.com 内核版本:Linux-3.14 u-boot版本:U-Boot 2015.04 硬件:TQ2440 (NorFlash:2M   Na ...

  9. CList 点击表头排序 (2)两种排序方法中其中一种

    上一篇讲解SortItem()方法如何使用,虽然都是抄别人的但是就是想让大家有个大概的了解 CList 点击表头排序 (1)SortItems函数 点击表头排序基本思路都是 1.首先响应HDN_ITE ...

随机推荐

  1. Oracle NVL与NVL2函数

    nvl( ) 函数 从两个表达式返回一个非 null 值. 语法 NVL(eExpression1, eExpression2) 参数 eExpression1, eExpression2 如果 eE ...

  2. 20165233 预备作业3 Linux安装及学习

    Linux学习记录 别出心裁的Linux命令学习法学习总结 (由于我的电脑是Mac,Linux安装省略) 操作系统的功能: 管家婆和服务生 博客中对于这两个词含义的解释为 管家婆:通过进程.虚拟内存和 ...

  3. [Z] Windbg以及vs debug使用

    Windbg 一篇中国人写的质量非常高的Windbg文章:篇中国人写的质量非常高的Windbg文章: http://www.yiiyee.cn/Blog/windbg/ code project上的W ...

  4. Rhythmk 学习 Hibernate 09 - Hibernate HQL

    1.初始数据 @Test public void test01() { Session session = null; try { session = HibernateUtil.getSession ...

  5. 自己创建js文件

    js文件的创建: /** * Created by Administrator on 2018/7/14. */ (function(arg){ var status = 1; $.extend({ ...

  6. sqlserver数据库导出成insert语句

    点击数据库名称右键=========>任务========>生成脚本 一.表结构导出成sql语句 二.数据导出成sql语句

  7. How To Install Spring IDE In Eclipse

    Spring IDE is a very useful graphical user interface tool adding support for Spring Framework. In th ...

  8. 23.Merge k Sorted Lists (Array, Queue; Sort)

    Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 思 ...

  9. 生产消费者队列(TaskCompletionSource)的应用

    using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Li ...

  10. Caffe 议事(三):从零开始搭建 ResNet 之 网络的搭建(中)

    上面2个函数定义好了,那么剩下的编写网络就比较容易了,我们在ResNet结构介绍中有一个表,再贴出来: Layer_name Output_size 20-layer ResNet Conv1 32 ...