【发布时间】:2015-04-10 10:26:10
【问题描述】:
我正在开发作为 Windows 通用应用程序一部分的 Windows Phone 8.1 应用程序。按照 Windows 通用应用程序中extending splash screens 的教程,我将 App.xaml.cs 更改为替换
if (!rootFrame.Navigate(typeof(SplashPage), e.Arguments))
{
throw new Exception("Failed to create splash page");
}
与
if (e.PreviousExecutionState != ApplicationExecutionState.Running)
{
var extendedSplash = new SplashPage(e.SplashScreen);
Window.Current.Content = extendedSplash;
}
但这意味着当我覆盖Window.Current.Content 时,我无法访问根框架。我想改用
SplashPage.SplashScreen = e.SplashScreen;
if (!rootFrame.Navigate(typeof(SplashPage), e.Arguments))
{
throw new Exception("Failed to create splash page");
}
但现在页面过渡了。Frame.Navigate 有一个覆盖,它需要一个额外的 NavigationTransitionInfo 参数,通常设置为其子类之一:
- CommonNavigationTransitionInfo(即从右侧滚入);
- SlideNavigationTransitionInfo(即向上滑动);或
- ContinuumNavigationTransitionInfo(即短暂放大)。
(N.B. James Croft 有一个很好的 blog post 展示了这些转换。)
但对于初始屏幕扩展,我需要页面立即显示,而不需要过渡(就像用新页面实例覆盖 Window.Current.Content 一样)。
如何将Frame.Navigate 设置为立即发生而不进行转换?
【问题讨论】:
-
我认为它应该可以工作,如果您禁用帧的默认转换 - 在 app.xaml.cs 文件中,其中创建了 rootFrame ,刚创建完,添加
rootFrame.ContentTransitions = null;. -
太棒了。这已经在 App.xaml.cs 中,但它引导我进入 Frame.Navigated 事件,我可以在其中更改处理程序以仅在
NavigationEventArgs.SourcePageType != typeof(SplashPage)时添加回过渡 -
您也可以考虑禁用框架的过渡,并在需要时为 xaml 中的每个页面定义它们。
标签: windows-runtime windows-phone-8.1 win-universal-app