0

我想让按钮在 windows Phone 中触摸时改变颜色,但唯一可用的手势是GestureType.Tap在点击完成后调用,因此在用户触摸按钮后颜色会改变。如何在触摸时立即检测到触摸?

        while (TouchPanel.IsGestureAvailable)
        {

            GestureSample gs = TouchPanel.ReadGesture();
            switch (gs.GestureType)
            {
               //this is called AFTER the tap
               case GestureType.Tap:
                    if (Restart.tapped(gs.Position))
                        Restart.selectDrawColor = Color.OrangeRed;
                    else
                        Restart.selectDrawColor = Color.White;

                    if (uploadScore.tapped(gs.Position))
                        uploadScore.selectDrawColor = Color.OrangeRed;
                    else
                        uploadScore.selectDrawColor = Color.White;

                    if (MainMenu.tapped(gs.Position))
                        MainMenu.selectDrawColor = Color.OrangeRed;
                    else
                        MainMenu.selectDrawColor = Color.White;
                    break;
            }

        }
4

1 回答 1

2

触摸屏幕不被视为手势,因此ReadGesture不会返回。您将需要调用TouchPanel.GetState()并查找任何TouchLocation具有Stateof 的对象Pressed

// using System.Linq;

TouchLocation[] newTouchLocations = TouchPanel.GetState()
    .Where(loc => loc.State == TouchLocationState.Pressed)
    .ToList();

根据文档TouchLocationState.Pressed表示:

这个触摸位置位置是新的。

于 2012-05-05T04:36:13.907 回答