似乎无法从Windows Phone 7中的TouchPanel获得触摸输入

我在Visual Studio中开始了一个新项目,并且一直在尝试使用静态TouchPanel类来获取输入。 我通过EnabledGestures属性启用了“Tap”手势,但是当我点击屏幕时手势没有注册(即TouchPanel.IsGestureAvailable返回false)。

其他东西,如Mouse.GetState()。LeftButton == ButtonState.Pressed永远不会certificate是真的,即使在我以前的项目(基于Microsoft示例项目)中它始终没有任何问题。

任何人都有任何想法,为什么我似乎无法从设备获得任何forms的输入?

以下是我如何设置它 – 在页面构造函数中我设置了手势类型:

// Constructor public MainPage() { InitializeComponent(); TouchPanel.EnabledGestures = GestureType.Tap; } 

然后,在主网格的XAML标记中,我将其链接到ManipulationCompleted事件处理程序:

   

然后,在同一个事件处理程序中:

 private void LayoutRoot_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e) { if (TouchPanel.IsGestureAvailable) { if (TouchPanel.ReadGesture().GestureType == GestureType.Tap) { Debug.WriteLine("A"); } } } 

在Silverlight项目中为我工作。 在XNA中,您还必须在构造函数中添加手势类型:

 public Game1() { graphics = new GraphicsDeviceManager(this); TargetElapsedTime = TimeSpan.FromTicks(333333); TouchPanel.EnabledGestures = GestureType.Tap; } 

然后在Update方法中,您具有相同的validation:

 protected override void Update(GameTime gameTime) { // Allows the game to exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); if (TouchPanel.IsGestureAvailable) { if (TouchPanel.ReadGesture().GestureType == GestureType.Tap) { Debug.WriteLine("A"); } } // TODO: Add your update logic here base.Update(gameTime); }