Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set Frame.Navigate to happen immediately with no transition?

I am working on a Windows Phone 8.1 app as part of a Windows Universal App. Following the tutorial on extending splash screens in Windows Universal Apps I changed my App.xaml.cs to replace

if (!rootFrame.Navigate(typeof(SplashPage), e.Arguments))
{
    throw new Exception("Failed to create splash page");
}

with

if (e.PreviousExecutionState != ApplicationExecutionState.Running)
{
    var extendedSplash = new SplashPage(e.SplashScreen);
    Window.Current.Content = extendedSplash;
}

However this meant that I lost access to the root frame when I overwrote Window.Current.Content. I would like to instead use

SplashPage.SplashScreen = e.SplashScreen;
if (!rootFrame.Navigate(typeof(SplashPage), e.Arguments))
{
    throw new Exception("Failed to create splash page");
}

But now the page transitions in. There is an override for Frame.Navigate which takes an additional NavigationTransitionInfo parameter, typically set to one of its subclasses:

  1. CommonNavigationTransitionInfo (i.e. roll in from the right);
  2. SlideNavigationTransitionInfo (i.e. slides up); or
  3. ContinuumNavigationTransitionInfo (i.e. a short zoom-in).

(N.B. James Croft has a good blog post showing these transitions.)

But for a splash screen extension I need the page to show immediately, without a transition (just as one gets by overwriting Window.Current.Content with the new page instance).

How do I set Frame.Navigate to happen immediately with no transition?

like image 379
dumbledad Avatar asked Mar 16 '23 11:03

dumbledad


1 Answers

I would try to disable default Frame.ContentTransitions by setting it to null, just after the rootFrame is created in App.xaml.cs file (don't forget to handle different events - Launched/ShareTarget/Activated - if needed):

rootFrame.ContentTransitions = null

once you have done that, pages shouldn't have transition. Then if you want, you can bring back or set new transitions for Frame's content upon specific circumstances, or set transitions for pages individually, for example in Page's XAML:

<Page.Transitions>
    <TransitionCollection>
        <EntranceThemeTransition/>
    </TransitionCollection>
</Page.Transitions>
like image 177
Romasz Avatar answered Mar 19 '23 00:03

Romasz