2012-02-22 22 views
3

我在頁面中有一個Pivot控件。確定樞軸輕彈和拖動是正確的還是在Windows Phone 7左?

<controls:Pivot x:Name="pvtSearchFlights"> 
       <toolkit:GestureService.GestureListener> 
        <toolkit:GestureListener DragCompleted="GestureListener_DragCompleted" Flick="GestureListener_Flick" /> 
       </toolkit:GestureService.GestureListener> 
       <controls:PivotItem x:Name="pvtItemCurrent"> 
        <StackPanel Height="700" Background="AliceBlue"> 
        </StackPanel> 
       </controls:PivotItem> 
       <controls:PivotItem x:Name="pvtItemNext"> 
        <StackPanel Height="700" Background="Red"> 
        </StackPanel> 
       </controls:PivotItem> 
       <controls:PivotItem x:Name="pvtItemPrevious"> 
        <StackPanel Height="700" Background="Green"> 
        </StackPanel> 
       </controls:PivotItem> 
      </controls:Pivot> 

在這裏我能找到輕拂是否向右或向左下面的代碼:

private void GestureListener_Flick(object sender, FlickGestureEventArgs e) 
     { 
      if (e.Angle > 90 && e.Angle < 270) 
      { 
       txtTest.Text = "right"; 
      } 
      else 
      { 
       txtTest.Text = "left"; 
      } 
     } 

如果我拖累樞軸轉動控制,樞軸項正發生改變,但GestureListener_Flick事件不是因爲它是一個拖拽事件(在這裏它觸發了GestureListener_DragCompleted事件)。所以,當我拖動我也必須找到它是否被拖動到左側或右側?

在這裏,我的主要目的是找到樞軸是從右到左還是從左到右?

我該如何找到它是向左還是向右拖?

在此先感謝。

+0

除了平移/拖動手勢之外,您還必須解決第三種更改項目的問題:點擊下一項的標題。 – murki 2012-06-01 02:25:21

回答

2

如何存儲Pivot的當前索引並添加SelectionChanged事件處理程序,然後比較舊的存儲索引和來自事件的新索引?

如果差異「新舊」是gt 0,它是在右邊,如果diff是lt 0,它是在左邊。當舊的或新的爲0時,您必須處理特殊狀態。