1

I want to create a photo gallery basically. I have a list of x items, and a pivot of 3 pages fixed. (I did this because I don't know in advance will I have 4 items or 1000)

When I'm browsing between the items and I reach the last one, I want to disable further paging to the right, or to the left if I reached the begining.

Is this possible, and how?

Thanks in advance.

Igor Meszaros
  • 2,081
  • 2
  • 22
  • 46
  • Check my answer in this thread: http://stackoverflow.com/questions/8775333/how-to-disable-the-pivot-flick-event/8775509#8775509 – keyboardP Jan 17 '12 at 17:56
  • Nice, this does the effect what I want, the only problem is that it seems like we are paging to a new navigation page. It would be nice to disable the animation – Igor Meszaros Jan 18 '12 at 11:57
  • I don't understand what you mean. You want to disable the Pivot animation? Wouldn't that just be a single page? – keyboardP Jan 18 '12 at 16:29
  • when you reach the last page, and you continue paging than you page to a same page, where instead you shouldn't be able to drag the screen that way. Sorry I don't know how else to explain. – Igor Meszaros Jan 19 '12 at 08:53
  • This link and the pages it links to might help on disabling animation. You can set them on the first and last pages: http://windowsphonegeek.com/tips/how-to-disable-pivot-panorama-swipe-gesture-sliding-inside-pivot-item – keyboardP Jan 19 '12 at 14:01
  • I thought about this solution as well, but... when I call myPivot.IsHitTestVisible = false; I wont be able to navigate back either. – Igor Meszaros Jan 19 '12 at 14:07
  • You could detect a horizontal swipe to the left to re-enable it and then manually move the pivot using SelectedIndex – keyboardP Jan 19 '12 at 14:14
  • sounds good. you can add that as an answer if you like – Igor Meszaros Jan 19 '12 at 14:22
  • I've added it as an answer :) – keyboardP Jan 19 '12 at 14:34

1 Answers1

2

You can use my answer here to determine when the user is on the first or last pivot item. Once you reach the the first or last pivot page, you can then disable the hit testing by using IsHitTestVisible=false as described on this page. To ensure that you can still swipe in the opposite direction, you can detect a horizontal swipe to the left to re-enable it and then manually move the pivot using SelectedIndex.

There are various ways of detecting a horizontal swipe such as using the gesture library or calculating it manually. You can get the starting position and the final position of the user's touch and determine if the difference in the X positions is positive (swiped to the right) or negative (swiped to the left) - assuming you're subtracting the initial position from the final one.

Community
  • 1
  • 1
keyboardP
  • 68,824
  • 13
  • 156
  • 205