How to disable the pivot flick event?

一曲冷凌霜 提交于 2019-12-05 04:43:14

问题


I'm designing a reading app with pivot control. When coming from the first page, I want to disable the right-flick event so that the user can just flick left to get to the next page. When coming from the last page, I want to disable the left-flick event.

There is a lockablePivot control in Silverlight Toolkit, but this control will disable all the flick event. Would anybody give me some suggestions.


回答1:


Have you looked at the LockablePivot Control in microsoft silverlight toolkit?

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




回答2:


I think you should rethink your design decision here. Metro design language states how pivots work and people are used to this. Changing this will make the user experience worse for people because they expect you to be able to flick round in the pivot.




回答3:


Using a PivotItem like this goes against the UI Guide and shouldn't really be implemented. However, for the sake of theory if nothing else, you could do something like this.

Give your first and last PivotItem a name.

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

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


来源:https://stackoverflow.com/questions/8775333/how-to-disable-the-pivot-flick-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!