0

我有一個Panorama頁面。我怎樣才能找出哪一方用戶滑動Panorama?我需要知道滑動方向如何找出用戶滑動Panorama的方向? (Windows Phone)

void DialogPanorama_ManipulationStarted(object sender, ManipulationStartedEventArgs e) 
     { 
      int selectedIndex = this.DialogPanorama.SelectedIndex; 
      int count = this.DialogPanorama.Items.Count; 
      for (int i = 0; i < count; ++i) 
      { 
       { 
        FeedItemViewModel curItem = this.DialogPanorama.Items[i] as FeedItemViewModel; 
        if (curItem != null) 
        { 
         if (Math.Abs(i - selectedIndex) > 1 && Math.Abs(Math.Abs(i - selectedIndex) - count) > 1) 
         { 
          curItem.ItemVisibility = System.Windows.Visibility.Collapsed; 
         } 
         else 
         { 
          curItem.ItemVisibility = System.Windows.Visibility.Visible; 
         } 
        } 
       } 
      } 
     } 

更新:

我覺得應該用這個做:

Point startPoint = e.ManipulationOrigin; 
      MouseState ms = Mouse.GetState(); 
+0

如果您知道幻燈片之前和幻燈片之後的頁面,可以輕鬆演繹出幻燈片的方向,也許我不明白你想要做什麼。 – Mentezza 2012-03-14 11:03:54

+0

這是非常困難的,然後找出幻燈片dirrection因爲頁面的數量變化dinamicaly – revolutionkpi 2012-03-14 11:12:51

+0

好的,但我發佈的代碼,也許它會幫助你一點點:) – Mentezza 2012-03-14 11:23:08

回答

3

我要做的是得到的座標在2個不同的時刻觸摸(短)。 如果座標B的橫座標高於座標A的橫座標,則用戶想要向左滑動。 如果座標B的橫座標是座標A的橫座標最低,那麼用戶想要向右滑動。

看看這裏(獲取觸摸位置):

http://msdn.microsoft.com/en-us/library/bb197572.aspx


編輯其他方式:

簡單的方法來推斷滑動的方向:

private void Panorama_SelectionChanged(object sender, SelectionChangedEventArgs e) 
    { 
     OldPage = ActualPage; 
     ActualPage = panorama.SelectedIndex; 
     MessageBox.Show("Old page: " + OldPage + "\n Actual Page: " + ActualPage); 
     if (OldPage < ActualPage) 
      MessageBox.Show("Direction of the slide: Right"); 
     else if (OldPage > ActualPage) 
      MessageBox.Show("Direction of the slide: Left"); 
     // else if(some other specific condition...) 

    } 



    private int OldPage { get; set; } 
    private int ActualPage { get; set; } 
+0

你能展示一個例子,它將是非常有用的 – revolutionkpi 2012-03-14 10:26:31

+0

這並不完全是我需要的 – revolutionkpi 2012-03-14 10:30:19

+0

嗨,我也在尋找同樣的問題。上面的例子只顯示真值和假值,但主要問題是如何找出全景的流向?從左到右或從右到左。 – BIBEKRBARAL 2012-07-24 08:45:39

相關問題