3

在全景应用程序中,我添加了几种情况,用户被导航回某个全景项目。然而,这是在一个突然的动作中完成的。有没有一种方法可以让我通过某种形式的过渡更顺利地完成这个动作?或者类似的东西?

4

2 回答 2

5

这段代码对我有用

SlideTransition slideTransition = new SlideTransition();
slideTransition.Mode = SlideTransitionMode.SlideRightFadeIn;
ITransition transition = slideTransition.GetTransition(panorama_main);
transition.Completed += delegate
{
    transition.Stop();
};
PanoramaItem pItem = (PanoramaItem)panorama_main.Items[3];
panorama_main.DefaultItem = pItem; 
transition.Begin();
于 2013-08-01T03:41:56.313 回答
0

从 Inder Kumar Rathore 在此页面中的回答和回答中,我来做到这一点:

    #region navigation
    public enum MainPanoramaItem
    {
        None = -1, Mag, Scan, Account, Lists, More, Help, MainPanoramaItemCount
    }
    public void PanoramaNavigateTo(MainPanoramaItemitem)
    {
        int count = (int)MainPanoramaItem.MainPanoramaItemCount;
        int toPosition = (int)item;
        int nowPosition = panorama.SelectedIndex;
        bool left = false;
        if(nowPosition > toPosition){
            int rightDelta = count - nowPosition + toPosition;
            int leftDelta = nowPosition - toPosition;
            left = rightDelta > leftDelta;
        } else {
            int leftDelta = count - nowPosition + toPosition;
            int rightDelta = nowPosition - toPosition;
            left = rightDelta > leftDelta;
        }

        SlideTransition slideTransition = new SlideTransition();
        slideTransition.Mode = left ? SlideTransitionMode.SlideLeftFadeOut : SlideTransitionMode.SlideRightFadeOut;
        ITransition transition = slideTransition.GetTransition(panorama);
        transition.Completed += delegate
        {
            transition.Stop();
            SlideTransition slideTransitionIn = new SlideTransition();
            slideTransitionIn.Mode = left ? SlideTransitionMode.SlideLeftFadeIn : SlideTransitionMode.SlideRightFadeIn;
            ITransition transitionIn = slideTransitionIn.GetTransition(panorama);
            transitionIn.Completed += delegate { transitionIn.Stop(); };

            panorama.SetValue(Panorama.SelectedItemProperty, panorama.Items[(int)item]);
            Panorama temp = panorama;
            LayoutRoot.Children.Remove(panorama);
            LayoutRoot.Children.Add(temp);
            LayoutRoot.UpdateLayout();

            transitionIn.Begin();
        };
        transition.Begin();
    }

    protected override void OnBackKeyPress(CancelEventArgs e)
    {
        if (panorama.DefaultItem != panorama.Items[(int)PanoramaItem.Mag])
        {
            PanoramaNavigateTo(PanoramaItem.Mag);
            e.Cancel = true;
        }
    }
    #endregion

在 MainPage.xaml.cs 它使用淡出然后淡入并将全景图的标题保留在其原始位置。我还不确定它对实际应用程序的反应,因为我的应用程序很空。

于 2014-11-19T13:41:08.537 回答