我在页面中有一个 Pivot 控件。
<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 事件)。所以当我拖动的时候我也必须找出它是被拖到左边还是右边?
这里我的主要目的是找出枢轴是从右向左移动还是从左向右移动?
如何判断是拖到左边还是右边?
提前致谢。
最佳答案
如何存储 Pivot 的当前索引并添加 SelectionChanged 事件处理程序,然后只比较旧存储的索引和事件中的新索引?
如果 diff "new - old"是 gt 0,它在右边,如果 diff 是 lt 0,它在左边。当 old 或 new 为 0 时,您必须处理特殊状态。
关于windows-phone-7 - 在 Windows Phone 7 中确定枢轴轻弹和拖动是向右还是向左?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9391966/