Simultaneous pressing of several buttons

In my WP 7.1 application, I have a page with several buttons.
I noticed that when any one button is pressed, no other button can be pressed.

How can I overcome this? I need users to be able to click multiple buttons at the same time.

+6
source share
1 answer

Unfortunately, you cannot handle multiple button presses. However, there is a way around. You can use the Touch.FrameReported event to get the position of all the points that the user touches the screen (I read somewhere before before I limited myself to two on WP7, but I can’t confirm this). You can also check if the action performed by the user (such as Down, Move, and Up) is being performed, which may be useful depending on what you are doing.

Put it in your Application_Startup

Touch.FrameReported += new TouchFrameEventHandler(Touch_FrameReported); 

Put it in your App class

 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 } } } 

In the "Do stuff here" section, you should check if TouchPoint tp is in the area the button occupies.

 //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. } 

This will hopefully do it for you.

+4
source

Source: https://habr.com/ru/post/919457/


All Articles