gpt4 book ai didi

windows-phone-8 - 枢轴滑动方向检测

转载 作者:行者123 更新时间:2023-12-03 23:36:44 25 4
gpt4 key购买 nike

我在 Windows Phone 8 中工作,并且在 Pivot 控件中有两个 Pivot 项。如何检测我是向右滑动还是向左滑动?

最佳答案

第 1 步:在您的解决方案中添加 Microsoft.Phone.Controls.Toolkit

第 2 步:在 xaml 中添加 Microsoft.Phone.Controls.Toolkit 引用,如下所示:

xmlns:tolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"

第三步:像这样创建手势监听器轻弹事件:

<Grid x:Name="LayoutRoot" Background="Transparent">
<tolkit:GestureService.GestureListener>
<tolkit:GestureListener Flick="GestureListener_Flick"></tolkit:GestureListener>
</tolkit:GestureService.GestureListener>
<!--Pivot Control-->
<controls:Pivot Title="MY APPLICATION">
<!--Pivot item one-->
<controls:PivotItem Header="item1">
<Grid/>
</controls:PivotItem>

<!--Pivot item two-->
<controls:PivotItem Header="item2">
<Grid/>
</controls:PivotItem>
</controls:Pivot>
</Grid>

第 4 步:在您的 cs 页面中添加此代码:

 private void GestureListener_Flick(object sender, FlickGestureEventArgs e)
{
if (e.Direction.ToString() == "Horizontal") //Left or right
{
if (e.HorizontalVelocity > 0) //Right
{

}
else //Left
{

}
}
}

you could download toolkit from here

关于windows-phone-8 - 枢轴滑动方向检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22861348/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com