触摸时不会导致 Silverlight OOB 应用程序中的按钮按下状态

发布于 2024-11-04 08:41:48 字数 740 浏览 0 评论 0原文

我目前正在使用 Silverlight4 构建一个支持触摸的 OOB 应用程序。我想我正在做的事情将符合“多点触控”的资格,即使我的应用程序在任何时候都没有使用多点触摸。我正在各种触摸显示器(标准 win7 多点触摸)上从浏览器运行该应用程序。

除了我的 SL 按钮控件(我只是使用标准控件)之外,一切似乎都正常。仅当触摸在触摸屏上移动相当大的距离后,按钮才会进入“按下”状态。如果用户将手指直接放在按钮上,我永远不会注意到按钮进入按下状态(但是点击效果很好)。

我会附加一些代码,但确实没有太多代码来驱动这个。这都是 xaml 中非常标准的 VisualStateManager 内容。即使这个普通的普通按钮也存在问题:

<Button Content="CLICKME"/>

我是否遗漏了任何明显的东西,或者这只是 Silverlight 中触摸输入的已知限制?

更新: 看起来这个问题只是因为标准 SL 按钮控件不适合处理触摸输入。 WPF 中的答案是简单地使用 Surface Toolkit 控件来正确处理触摸,但这不适用于 SL,因为我无法使用 WPF 程序集。 http://www.triballabs.net/ 2011/03/reactive-ui-in-windows-touch-and-surface/

I am currently using Silverlight4 to build an OOB app with touch support. I guess what I'm doing would qualify as "multitouch" even though my app isn't using multiple touches at any point. I am running the app out of browser on various touch displays (standard win7 multitouch).

Everything seems to be working except for my SL button controls (I'm just using the standard control). The buttons only enter their "press" state after a touch has been moved a fairly large amount on the touch screen. If a user places their finger down directly on a button, I'm never noticing the button entering the press state (clicks come through fine however).

I would attach some code but there really isn't much code that is driving this. It is all very standard VisualStateManager stuff in xaml. Even this plain vanila button has the issue:

<Button Content="CLICKME"/>

Is there anything obvious I am missing or is this just a known limitation with touch input in Silverlight?

UPDATE:
It looks like this issue is simply that the standard SL button control is not made to handle touch input. The answer in WPF is to simply use the Surface Toolkit controls which do handle touch correctly however this does not work for SL as I can't use a WPF assembly.
http://www.triballabs.net/2011/03/reactive-ui-in-windows-touch-and-surface/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜中书 2024-11-11 08:41:49

我可以通过在我的应用程序中注册 Touch.FrameReported 处理程序来解决此问题。我不确定为什么这会起作用,因为我的处理程序实际上没有执行任何操作,但由于某种原因按下按钮立即开始工作。请注意,这仅适用于非全屏应用程序(全屏 SL 应用程序似乎不支持触摸)。代码如下:

(in Application_Startup)
Touch.FrameReported += new TouchFrameEventHandler( Touch_FrameReported );

(in my App class)
void Touch_FrameReported( object sender, TouchFrameEventArgs e ) {}

似乎注册 Touch.FrameReported 处理程序的行为改变了触摸事件提升为鼠标事件的方式。不知道为什么会这样,但它对我有用。

I was able to fix this issue by registering a Touch.FrameReported handler in my application. I'm not sure why this is working as my handler doesn't actually do anything but for some reason button presses immediately started working. Note that this only works in a non-fullscreen application (fullscreen SL apps don't seem to support touch). Here is the code:

(in Application_Startup)
Touch.FrameReported += new TouchFrameEventHandler( Touch_FrameReported );

(in my App class)
void Touch_FrameReported( object sender, TouchFrameEventArgs e ) {}

It seems that the very act of registering a Touch.FrameReported handler changes the way that Touch events are promoted to mouse events. Not sure why this would be but it did the trick for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文