2011-01-11 97 views
1

我在Pivot控件中的圖像列表中。如果您觸摸圖片,則會導航到另一個視圖。如果通過新的支點輕彈並同時觸摸圖像,則導航。在Windows Phone上取消觸摸事件

我注意到Facebook應用程序或本地相冊沒有這個錯誤。

有什麼想法?

編輯:代碼:

      Image img = new Image(); 
          Delay.LowProfileImageLoader.SetUriSource(img, new Uri(adViewModel.Photos[k].ThbUrl)); 
          img.Width = 150; 
          img.Tag = k; 
          img.Height = 150; 
          img.MouseLeftButtonDown += new MouseButtonEventHandler(launch_Diapo); 
          Grid.SetRow(img, i); 
          Grid.SetColumn(img, j); 

          PhotosGrid.Children.Add(img); 

回答

2

如果你能證明你的代碼,我們可以大概提供了更明確的答案。

但是:

我猜你使用MouseButtonLeftDown或類似的檢測圖像的觸摸。而不是使用toolkit中的Tap手勢。這應該可以防止你遇到的問題。

還有一種可能的選擇,在您觸摸圖像時禁用樞軸手勢,但根據您在pivotItem中使用圖像的方式,最終可能導致無法正確旋轉導航。

你可以像這樣的代碼添加Tap事件:

var gl = GestureService.GetGestureListener(img); 

gl.Tap += new EventHandler<GestureEventArgs>(gl_Tap); 

和處理程序將是這樣的。 (但實際上做了一些有用的事情 - 顯然)。

void gl_Tap(object sender, GestureEventArgs e) 
{ 
    MessageBox.Show("tapped"); 
} 
+0

我加了我的代碼,可能是MouseButtonLeftDown,因爲我沒有使用tap。我怎樣才能以編程方式使用水龍頭?我只看到了xaml的例子。我需要創建一個GestureListener,但是如何將其綁定到我的圖像? – 2011-01-11 15:14:49

+0

@Thomas添加示例 – 2011-01-13 12:56:18

0

即使我有類似的問題。我所做的是,檢查MouseButtonLeftDown位置和MouseButtonLeftUp的位置。如果它們是等號導航,否則什麼也不做。我會粘貼下面的代碼。

Point temp; 

void img_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
{ 
    temp = e.GetPosition(null); 
} 

void img_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) 
{ 
    Point point = e.GetPosition(null); 
    if (point == temp) 
    { 
     this.NavigationService.Navigate(new Uri(...)); 
    } 
}