在全景应用程序中,我添加了一些用户导航回某个全景项目的情况。然而,这是在一次突然的运动中完成的。有什么方法可以通过某种形式的过渡更顺利地完成这项行动?或类似的东西?
答案 0 :(得分: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();
答案 1 :(得分: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中的它使用淡出然后淡入并将全景的标题保留在它的原始位置。 我还不确定它是如何对真实应用做出反应的,因为我的应用很空白。