windows-phone-7 - 在 Windows Phone 7 中确定枢轴轻弹和拖动是向右还是向左?

标签 windows-phone-7

我在页面中有一个 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/

相关文章:

c# - 更新应用程序时的 WP7 隔离存储

windows-phone-7 - 检查操作系统版本 windows phone 7

sockets - Windows Phone 7.1 是否支持 SSL 套接字?

windows-phone-7 - 锁定屏幕中的芒果提醒

windows-phone-7 - Windows Phone 7 的 jQuery Mobile 替代品?

silverlight - 如何更改 Silverlight for Windows Phone 上 Web 浏览器上的 ComboBox "selectedIndex"?

windows-phone-7 - 自定义 Storyboard中的 "Cannot resolve TargetName"错误

c# - ♥ 字符在 Glyphs 中显示不正确

windows-phone-7 - Fire ManipulationStarted 在 WP7 中手动启动

c# - 如何在 C# 中将两个整数转换为浮点值?