在 Windows Phone 8.1 枢轴控件中禁用滑动手势 [英] Disabling swipe gesture in Windows Phone 8.1 pivot control

查看:20
本文介绍了在 Windows Phone 8.1 枢轴控件中禁用滑动手势的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个通用应用.对于 Windows Phone 部分,我已经在其中实现了一个透视页面.现在,我希望禁用数据透视页面中的滑动手势(用于浏览不同的数据透视项),以便仅在点击第一个数据透视项上的按钮时才显示第二个数据透视项.我尝试将 Pivot 控件的 IsHitTestVisible 属性设置为 false,但随后所有 PivotItem 都被阻止.

I am making a Universal app. For the windows phone part I have implemented a pivot page in it. Now I want the swipe gesture (for navigating through different pivot items) in pivot page to be disabled so that only when a button on the first PivotItem is tapped then it shows the second PivotItem. I tried setting the IsHitTestVisible property of the Pivot control to false but then all the PivotItem are blocked.

推荐答案

它违背了 WINDOWS UI 指南,不应该真正实施.

It goes against the WINDOWS UI Guide and shouldn't really be implemented.

然而,为了理论,如果没有别的,你可以做这样的事情.

However, for the sake of theory if nothing else, you could do something like this.

假设您有 5 个数据透视项,将第一个和最后一个数据透视项命名为

Consider you have 5 pivot items, give your first and last PivotItem a name as

<controls:PivotItem Header="Item1" Name="first">
...

 <controls:PivotItem Header="Item5" Name="last">

处理 Pivot 的 LoadingPivotItemLoadedPivotItem 事件.然后你可以做这样的事情:

Handle the Pivot's LoadingPivotItem and LoadedPivotItem events. You can then do something like this:

//class level variable we use for the current pivot
PivotItem currentItem = null;

private void Pivot_LoadingPivotItem(object sender, PivotItemEventArgs e)
{
//if the next item is going to be "first" pivot
//and the previous item was the "last" pivot...
if (e.Item == first && currentItem == last)
{
  //...reset the Pivot back to the last one.
   mainPivot.SelectedItem = last;
}

//same theory as above but checking if we're 
//sliding to the last one from the first one
if (e.Item == last && currentItem == first)
{
   mainPivot.SelectedItem = first;
}
}

private void mainPivot_LoadedPivotItem(object sender, PivotItemEventArgs e)
{
 //once the pivot is loaded, update the currentItem
 currentItem = e.Item;
}

希望这有效..如有任何疑问,请回复.

Hope this works.. For any queries .. revert back.

这篇关于在 Windows Phone 8.1 枢轴控件中禁用滑动手势的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆