如何以编程方式点击Wp8屏幕

时间:2013-12-16 10:24:11

标签: xaml windows-phone-7 c#-4.0 windows-phone-8 gesture-recognition

在我的应用程序中,我正在处理点击事件,通过点击我的WP屏幕,我在文本块中显示X,Y坐标。 现在尝试在屏幕上以编程方式点按X,Y坐标。 我怎么能这样做。

听到我的代码来获取X,Y值

 private void GestureListener_Tap(object sender, 
        Microsoft.Phone.Controls.GestureEventArgs e)
        {
        try
        {
          Point tapLocation = e.GetPosition(viewfinderCanvas);
        if (tapLocation != null)
        {
          focusBracket.SetValue(Canvas.LeftProperty,
        tapLocation.X);
          focusBracket.SetValue(Canvas.TopProperty, 
        tapLocation.Y);
          double tapX = tapLocation.X;
          double tapY = tapLocation.Y;
          focusBracket.Visibility = Visibility.Visible;
        this.Dispatcher.BeginInvoke(delegate()
        {
          this.txtDebug.Text = string.Format("Tapping Coordinates are X={0:N2}, Y={1:N2}", tapX, tapY);
        });
        }
        }
        catch (Exception error){
        this.Dispatcher.BeginInvoke(delegate()
        {
          txtDebug.Text = error.Message;

        }); }}

先谢谢

0 个答案:

没有答案