Reputation: 1210
I understand this question has been asked before, but never for Windows Phone 8 has it been answered.
In Windows Phone 7, it was possible to set isHitTestVisible = false
on the base Pivot
element to stop the PivotItem from scrolling when swiping over certain elements, like Sliders and TextBoxes. In Windows Phone 8, however, the Pivot beings scrolling before the ManipulationStarted
event (or even the Touch
object's events) fires. This means that one cannot prevent scrolling between Pivots by listening for ManipulationStarted on certain Controls like one could in Windows Phone 7.
Is there any way to disable scrolling over certain elements, or even certain sections of the screen?
Upvotes: 6
Views: 3938
Reputation: 7350
For UWP I wanted to use Pivot more like tabs control so I'd to override the pivot style and there is an element Pivot Panel so if we disable ManipulationMode=None swipe will be disabled and it'll work more like tabs.
<PivotPanel x:Name="Panel" VerticalAlignment="Stretch" ManipulationMode="None">
Upvotes: 3
Reputation: 26347
If your actual problem is that the Pivot swallow manipulation events for map/slider/etc. controls, try set UseOptimizedManipulationRouting="False"
.
MSDN have a longer explanation of this property.
Otherwise the correct approach is to use Pivot.IsLocked="True"
.
Upvotes: 14
Reputation: 4321
I suggest you using WP Silverlight Tolkit, they provide nice gesture events, and you'r event is WhenFlicked().
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener Flick="WhenFlicked"/>
</toolkit:GestureService.GestureListener>
Function:
if (e.Direction.ToString() == "Horizontal") //Left or right
{
if (e.HorizontalVelocity > 0) //Right
{
Pivot.CurrentItem=Pivot.CurrentItem+1; //don't remember the code for changing the page...
}
else //Left
{
Pivot.CurrentItem=Pivot.CurrentItem-1;
}
}
I also tried writing my swipe event, but this one is way better and doesn't trigger events of elements placed on the page. Good Luck
Upvotes: 0