我正在尝试根据选择的旋转项目位置为图像设置动画。
我目前正在使用ManipulationDelta事件尝试查看用户正在滑动的方向,以便我可以根据枢轴项目的位置淡出或淡入动画图像。
我的问题在于ManipulationDelta事件,此事件仅在枢轴项上调用一次,无论旋转控件的操作程度如何。
有没有人知道如何制作它,以便在操作ManpulationDelta事件时不断调用它?
答案 0 :(得分:0)
可能您的Pivot
正在拦截其他事件。您可以尝试执行此操作 - 禁用Pivot
(然后您的操作应该有效)并手动更改PivotItems
,例如使用TouchPanel和Touch.FrameReported。示例代码:
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;
}
}
}