Windows phone 8 以编程方式在Windows Phone 8应用程序中无法进行横向滑动

Windows phone 8 以编程方式在Windows Phone 8应用程序中无法进行横向滑动,windows-phone-8,Windows Phone 8,我是windows phone开发的初学者,我在旋转木马视图中以纵向方向滑动图像,并尝试横向方向,但未成功。请任何人帮助我解决此问题 TouchPoint _first; private List<TList> _pivotList; public Pivot() { InitializeComponent(); Loaded += pivot_Loaded; Touch.FrameReported += Touch_FrameReported; }

我是windows phone开发的初学者,我在旋转木马视图中以纵向方向滑动图像,并尝试横向方向,但未成功。请任何人帮助我解决此问题

TouchPoint _first;

private List<TList> _pivotList;

public Pivot()
{
    InitializeComponent();
    Loaded += pivot_Loaded;
    Touch.FrameReported += Touch_FrameReported;
}







private void Touch_FrameReported(object sender, TouchFrameEventArgs e)

{ 

TouchPoint mainTouch = e.GetPrimaryTouchPoint(null);

if (mainTouch.Action == TouchAction.Down)

    _first = mainTouch;

else if (mainTouch.Action == TouchAction.Up)

{
    var xDelta = mainTouch.Position.X - _first.Position.X;

    var yDelta = Math.Abs(mainTouch.Position.Y - _first.Position.Y);

    if (yDelta > Math.Abs(xDelta))

        return;

    if (Math.Abs(xDelta - 0) > 10)

    {

        var currentIndex = pivotList.SelectedIndex;

        int noOfPivotItems = pivotList.Items.Count;


        currentIndex = (xDelta < 0) ?

            ++currentIndex % noOfPivotItems :
            (--currentIndex + noOfPivotItems) % noOfPivotItems;
        pivotList.SelectedIndex = currentIndex;

    }

}

}
TouchPoint\u首先;
私有列表_数据透视列表;
公共支点()
{
初始化组件();
加载+=轴加载;
Touch.FrameReported+=Touch\u FrameReported;
}
私有void Touch_FrameReported(对象发送方,TouchFrameEventArgs e)
{ 
接触点mainTouch=e.GetPrimaryTouchPoint(空);
if(mainTouch.Action==TouchAction.Down)
_first=mainTouch;
else if(mainTouch.Action==TouchAction.Up)
{
var xDelta=mainTouch.Position.X-_first.Position.X;
var yDelta=Math.Abs(mainTouch.Position.Y-_first.Position.Y);
if(yDelta>Math.Abs(xDelta))
返回;
如果(数学绝对值(xDelta-0)>10)
{
var currentIndex=pivotList.SelectedIndex;
int noOfPivotItems=pivotList.Items.Count;
currentIndex=(xDelta<0)?
++当前索引%noOfPivotItems:
(-currentIndex+noOfPivotItems)%noOfPivotItems;
pivotList.SelectedIndex=currentIndex;
}
}
}

以下是显示方向的代码

public Pivot()
{
    InitializeComponent();
    Loaded += pivot_Loaded;
            this.navigationHelper = new NavigationHelper(this);
            Windows.Graphics.Display.DisplayInformation.AutoRotationPreferences = Windows.Graphics.Display.DisplayOrientations.Landscape;
            Windows.Graphics.Display.DisplayInformation.AutoRotationPreferences = Windows.Graphics.Display.DisplayOrientations.PortraitFlipped;


        }

很抱歉,它不起作用。如果我将xdelta、ydelta函数正确地赋给横向,您还有其他想法吗?它会起作用的,因为我尝试这样左右递增滑动。if(Math.Abs(ydelta-0)>10){var currentIndex=pivotList.SelectedIndex;int noOfPivotItems=pivotList.Items.Count;currentIndex=(yDelta<0)?++currentIndex%noOfPivotItems:(-currentIndex+noOfPivotItems)%noOfPivotItems;pivotList.SelectedIndex=currentIndex;}