Windows runtime 如何设置帧。导航到立即发生而不转换?
我正在开发Windows Phone 8.1应用程序,作为Windows Universal应用程序的一部分。在Windows Universal Apps教程之后,我将我的App.xaml.cs更改为Windows runtime 如何设置帧。导航到立即发生而不转换?,windows-runtime,windows-phone-8.1,win-universal-app,Windows Runtime,Windows Phone 8.1,Win Universal App,我正在开发Windows Phone 8.1应用程序,作为Windows Universal应用程序的一部分。在Windows Universal Apps教程之后,我将我的App.xaml.cs更改为 if (!rootFrame.Navigate(typeof(SplashPage), e.Arguments)) { throw new Exception("Failed to create splash page"); } 与 然而,这意味着我在重写Window.Current.
if (!rootFrame.Navigate(typeof(SplashPage), e.Arguments))
{
throw new Exception("Failed to create splash page");
}
与
然而,这意味着我在重写Window.Current.Content
时失去了对根框架的访问。我想改用
SplashPage.SplashScreen = e.SplashScreen;
if (!rootFrame.Navigate(typeof(SplashPage), e.Arguments))
{
throw new Exception("Failed to create splash page");
}
但现在页面在中转换。有一个覆盖,它使用一个额外的NavigationTransitionInfo
参数,通常设置为其子类之一:
Window.Current.Content
一样)
如何将
Frame.Navigate
设置为立即发生而不进行转换?我会在App.xaml.cs文件中创建根框架后,将其设置为null,尝试禁用默认Frame.ContentTransitions(如果需要,请不要忘记处理不同的事件-已启动/共享目标/已激活):
rootFrame.ContentTransitions=null
一旦这样做了,页面就不应该有转换。然后,如果需要,您可以根据特定情况为框架的内容返回或设置新的转换,或者单独为页面设置转换,例如在页面的XAML中:
对于那些希望对Windows 10 UWP应用程序执行相同操作的人,可以通过以下方式实现:
// Navigate to your first page without a transition
Frame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo());
根据。我认为它应该可以工作,如果您在app.xaml.cs文件中禁用框架的默认转换,在创建根框架后,添加
rootFrame.ContentTransitions=null代码>太棒了。这已经存在于App.xaml.cs中,但它将我引向Frame.Navigated事件,在该事件中,如果NavigationEventArgs.SourcePageType!=typeof(SplashPage)
如果需要,您也可以考虑禁用帧的转换,并在xaml中为每个页面定义它们。我正在Windows 10通用应用程序中使用WebView,动画导致“页面加载闪烁”。在AppShell.xaml中删除解决了这个问题。
// Navigate to your first page without a transition
Frame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo());