如何使WPF C#触摸屏按钮响应 [英] How to make WPF C# touch screen button responsive

查看:829
本文介绍了如何使WPF C#触摸屏按钮响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究触摸屏应用程序。按下按钮时,它将捕获50张图像。但我的问题是按钮不会释放,直到所有50张图像都来到我的电脑(通过TCP / IP)。然后如何使我的按钮按下并释放以在单独的线程而不是UI线程中运行。



我尝试过:



按钮TouchDown和TouchUp正在发生但是,它需要时间才能发布我的意思是TouchUp

Hi, i am working on a touch screen application. when you press a button it will capture 50 images. but my problem is button is not releasing until all the 50 images comes to my PC(Via TCP/IP). then how to make my button press and release to be run in separate thread rather than UI thread.

What I have tried:

Button TouchDown and TouchUp is happening but, its taking time to release i mean TouchUp

推荐答案

使用< a href =https://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker(v=vs.110).aspx> BackgroundWorker [ ^ ]:

使用BackgroundWorker进行多线程 - 完整的WPF教程 [ ^ ]



或者使用 async 等待

使用Async和Await来更新UI线程Stephen Haunts {在战壕中编码} [ ^ ]
Use a BackgroundWorker[^]:
Multi-threading with the BackgroundWorker - The complete WPF tutorial[^]

Or use async and await:
Using Async and Await to update the UI Thread | Stephen Haunts { Coding in the Trenches }[^]


你好,对不起,我无法帮你解决问题,但我可能会问你如何为按钮定义TouchDown和TouchUp?

我所做的是:

hello,i am sorry i can't help you with your problem,but may i ask you how to define TouchDown and TouchUp for a button?
what i have done is :
<Button Content="Button" TouchDown="touch_down" HorizontalAlignment="Left" Margin="221,116,0,0" VerticalAlignment="Top" Width="194" Height="75" />




private void touch_down(object sender, TouchEventArgs e)
{
MessageBox.Show("button touched down");
}





它没有回应,怎么了?你能帮帮我吗?



it has no response,what's wrong? Can you help me ?


这篇关于如何使WPF C#触摸屏按钮响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆