【问题标题】:Disabling swipe gesture in Windows Phone 8.1 pivot control在 Windows Phone 8.1 枢轴控件中禁用滑动手势
【发布时间】:2015-01-07 05:51:29
【问题描述】:
我正在制作一个通用应用程序。对于 windows phone 部分,我已经在其中实现了一个数据透视页面。现在我希望禁用数据透视页面中的滑动手势(用于导航不同的数据透视项目),以便只有当第一个数据透视项上的按钮被点击时,它才会显示第二个数据透视项。我尝试将 Pivot 控件的 IsHitTestVisible 属性设置为 false,但随后所有 PivotItem 都被阻止了。
【问题讨论】:
标签:
xaml
windows-phone-8.1
win-universal-app
【解决方案1】:
它违反了WINDOWS UI 指南,不应该真正实施。
但是,出于理论考虑,如果不出意外,您可以这样做。
假设您有 5 个数据透视项,请将您的第一个和最后一个数据透视项命名为
<controls:PivotItem Header="Item1" Name="first">
...
<controls:PivotItem Header="Item5" Name="last">
处理 Pivot 的 LoadingPivotItem 和 LoadedPivotItem 事件。然后你可以这样做:
//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;
}
希望这有效..
对于任何查询.. 恢复。