开发者

Touch down not causing button press state in Silverlight OOB app

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 tou开发者_运维知识库ch 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/


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜