0

如何根据导航到/从哪个页面在 Windows Phone 应用程序中实现多个页面转换?

例如,我有主页、设置页面和详细信息页面。我希望当我去往/离开设置页面时转换是旋转的,当我去往细节页面时是旋转栅门。

我怎样才能做到这一点?

4

1 回答 1

1

这篇GeekChamp文章涵盖了您使用Windows Phone Toolkit为页面过渡和其他元素设置动画的所有各种方式...

http://www.geekchamp.com/articles/windows-phone-7-navigation-transitions-step-by-step-guide

在文章的最后是如何根据按钮点击动态设置动画的示例......

1.定义动画

private void StartTransition()
{
    RotateTransition rotatetransition = new RotateTransition();
    rotatetransition.Mode = RotateTransitionMode.In90Clockwise;

    PhoneApplicationPage phoneApplicationPage =
    (PhoneApplicationPage)(((PhoneApplicationFrame)Application.Current.RootVisual)).Content;

    ITransition transition = rotatetransition.GetTransition(phoneApplicationPage);
    transition.Completed += delegate
    { 
        transition.Stop(); 
    };
    transition.Begin();
}

2. 按钮点击调用动画

private void btnRotate_Click(object sender, RoutedEventArgs e)
{
    NavigationService.Navigate(new Uri("/Page2.xaml", UriKind.Relative));
    StartTransition();
}

或根据页面名称导航时

protected override void OnNavigatedFrom(NavigationEventArgs e)
{
    base.OnNavigatedFrom(e);

    if (e.Uri.ToString().Contains("SlidePage"))
    {
        slideAnimation();
    }

    if (e.Uri.ToString().Contains("TurnstilePage"))
    {
        turnstileAnimation();
    }
}
于 2013-05-05T13:22:33.383 回答