ManipulationDelta on pivot item only fires once

*爱你&永不变心* 提交于 2019-12-23 05:26:15

问题


I am trying to animate an image based on the select pivoted items position.

I am currently using the ManipulationDelta event to try and see which direction the user is swiping so that I can fade out or fade in an animated image based on the position of the pivot item.

My problem is with the ManipulationDelta event, this event is only ever called once on a pivot item, regardless of how much manipulation of the pivot control is occurring.

Does anyone know a way to make it so the pivot items ManpulationDelta event is constantly called when it is being manipulated?


回答1:


Probably your Pivot is intercepting further events. You may try to do such a thing - disable Pivot (then your Manipulations should work) and change PivotItems manually for example using TouchPanel and Touch.FrameReported. Sample code:

public MainPage()
{
   InitializeComponent();
   myPivot.IsHitTestVisible = false; // disable your Pivot
   Touch.FrameReported += Touch_FrameReported;
   TouchPanel.EnabledGestures = GestureType.HorizontalDrag; 
}

TouchPoint first;
private const int detectRightGesture = 20;

private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
    TouchPoint mainTouch = e.GetPrimaryTouchPoint(this);
    if (mainTouch.Action == TouchAction.Down)
        first = mainTouch;
    else if (mainTouch.Action == TouchAction.Up && TouchPanel.IsGestureAvailable)
    {
        if (mainTouch.Position.X - first.Position.X < -detectRightGesture)
        {
            if (myPivot.SelectedIndex < myPivot.Items.Count - 1) myPivot.SelectedIndex++;
            else myPivot.SelectedIndex = 0;
        }
        else if (mainTouch.Position.X - first.Position.X > detectRightGesture)           
        {
            if (myPivot.SelectedIndex > 0) myPivot.SelectedIndex--;
            else myPivot.SelectedIndex = myPivot.Items.Count - 1;
        }
    }
}


来源:https://stackoverflow.com/questions/24188996/manipulationdelta-on-pivot-item-only-fires-once

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