操作旋钮上的操作只会触发一次 [英] ManipulationDelta on pivot item only fires once

查看:135
本文介绍了操作旋钮上的操作只会触发一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试基于选择的枢轴项目位置来动画化图像。



我正在使用ManipulationDelta事件来尝试查看用户正在滑动的方向,以便我可以根据自己的位置淡出或淡出动画图像枢纽项目。



我的问题是使用ManipulationDelta事件,这个事件只能在一个枢纽项目中被调用一次,而不管是多少操纵数据透视控件。有没有人知道这样做的方法,因为在被操纵时,ManpulationDelta事件是不断被调用的?

解决方案

可能您的数据透视正在截获更多事件。您可能会尝试这样做 - 禁用 Pivot (然后您的操作应该工作),并手动更改 PivotItems 使用 TouchPanel Touch.FrameReported 。示例代码:

  public MainPage()
{
InitializeComponent();
myPivot.IsHitTestVisible = false; //禁用您的Pivot
Touch.FrameReported + = Touch_FrameReported;
TouchPanel.EnabledGestures = GestureType.Horizo​​ntalDrag;
}

TouchPoint第一;
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;
}
}
}


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?

解决方案

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

这篇关于操作旋钮上的操作只会触发一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆