【问题标题】:How to disable the pivot flick event?如何禁用枢轴轻弹事件?
【发布时间】:2012-01-08 04:13:06
【问题描述】:

我正在设计一个带有枢轴控制的阅读应用程序。当来自第一页时,我想禁用右滑事件,以便用户只需向左滑即可进入下一页。从最后一页来时,我想禁用左滑事件。

Silverlight Toolkit 中有一个 lockablePivot 控件,但该控件将禁用所有轻弹事件。谁能给我一些建议。

【问题讨论】:

    标签: windows-phone-7 pivot windows-phone-7.1


    【解决方案1】:

    您看过 microsoft silverlight 工具包中的 LockablePivot 控件吗?

    http://www.windowsphonegeek.com/articles/Windows-Phone-Toolkit-LockablePivot-in-depth

    【讨论】:

      【解决方案2】:

      我认为您应该在这里重新考虑您的设计决定。 Metro 设计语言说明了枢轴的工作方式以及人们对此的习惯。更改此设置会使人们的用户体验变得更糟,因为他们希望您能够在枢轴上轻弹。

      【讨论】:

      • 感谢您的建议。实际上我已经重写了枢轴,所以它看起来不像枢轴控件。
      【解决方案3】:

      像这样使用 PivotItem 违反了 UI 指南,因此不应该真正实施。但是,出于理论考虑,如果不出意外,您可以这样做。

      为您的第一个和最后一个 PivotItem 命名。

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

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

      //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;
      }
      

      【讨论】:

      • 工作完美,除非您只有两个 PivotItems
      猜你喜欢
      • 2011-05-15
      • 1970-01-01
      • 2021-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多