同时按下多个按钮

在我的WP 7.1应用程序中,我有一个带有多个按钮的页面。
我注意到,当按下任何一个按钮时,不能按任何其他按钮。

我怎么能克服这个? 我需要能够允许用户同时按下多个按钮。

不幸的是,您无法一次处理多个按钮点击。 虽然有一种解决方法。 您可以使用Touch.FrameReported事件来获取用户在屏幕上触摸的所有点的位置(我在WP7之前的某处读过它仅限于两个,但我无法validation)。 您还可以检查用户正在采取的操作(例如,向下,向上和向上),这可能是有用的,具体取决于您正在做什么。

把它放在你的Application_Startup中

Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported); 

把它放在你的App类中

 void Touch_FrameReported(object sender, TouchFrameEventArgs e) { TouchPoint primaryTouchPoint = args.GetPrimaryTouchPoint(null); TouchPointCollection touchPoints = args.GetTouchPoints(null); foreach (TouchPoint tp in touchPoints) { if(tp.Action == TouchAction.Down) { //Do stuff here } } } 

在“Do stuff here”部分中,您将检查TouchPoint tp是否位于按钮占用的区域内。

 //This is the rectangle where your button is located, change values as needed. Rectangle r1 = new Rectangle(0, 0, 100, 100); if (r1.Contains(tp.Position)) { //Do button click stuff here. } 

希望能为你做到这一点。