"Deletes the turnstile navigation to run." What kind?

Below is the code in the default templates for creating XAML WP8.1 applications. (Universal / WinRT).

What is this code used for? I can't seem to get a breakpoint if rootFrame.ContentTransitions != null . It would be great for the application to provide its own opening animation instead of a turnstile. For example. like a cortana.

In App.xaml.cs

 #if WINDOWS_PHONE_APP // Removes the turnstile navigation for startup. if (rootFrame.ContentTransitions != null) { _transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { _transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; #endif 

Edit: the hint I found is that if all of the above code is commented out, then the turnstile page transitions are everywhere. Now, if only you uncomment: rootFrame.ContentTransitions = null; , all page turnstile transitions will be deleted. This is strange because ContentTransitions was empty before the installer, but the transitions are different if the setter is set to null.

Edit Edit: It looks like this code is required due to the state of the OS race. If all code is commented out, with the exception of zeroing ContentTransitions in rare times, the application has an animation of turnstiles.

+7
windows-phone windows-runtime winrt-xaml
source share
2 answers

Update (December 3, 2014)

I just discovered a way to use animations to β€œhide” an OS level turnstile when the application loads for the first time.

This requires three things -

  • There is no popup image in the application.
  • ContentTransitions set to null on the NavigatedTo main page.
  • Create a PageIn animation and animate the main page LayoutRoot with the background color - basically, to first align it with the background color of the system, and then animate it to whatever color you want in a short amount of time.

You can download the sample from here .


If you have all the code commented out. Do you think ContentTransitions should be null right? At least that's what I thought.

The answer is no . ContentTransitions will ContentTransitions be assigned to NavigationThemeTransition .

This may be because the Frame style has these lines of code by default.

 <Setter Property="ContentTransitions"> <Setter.Value> <TransitionCollection> <NavigationThemeTransition/> </TransitionCollection> </Setter.Value> </Setter> 

However, this Frame property is set very late. If you put a breakpoint in the constructor of your MainPage . You will see it still null . But if you put another breakpoint in OnNavigatedTo , you will see both this.Frame and this.Frame.ContentTransitions with values ​​in them.

What if I uncomment

 rootFrame.ContentTransitions = null; 

I believe that there is no if (_contentTransitions != null) return; in the customizer of this property if (_contentTransitions != null) return; check, when you set it to null , there must be something that prevents it from getting the default value of NavigationThemeTransition , and why you are not doing this, Don't watch the turnstile animation anymore.

However, there is another animation , you will always see, no matter what you do.

Try pausing your application by pressing the back key or home and reactivate it. Yes, the turnstile animation is back! Although I think this turnstile animation is different from the ones we disabled in Frame.ContentTransitions . Take a look at how the application launches for the first time - a splash screen with turnstile animation. I guess this is the same thing, and it is probably controlled by the OS.

So why do they put in this check?

 if (rootFrame.ContentTransitions != null) 

My guess is that since there is an animation of OS level turnstiles, if you do not provide a screen saver, the OS will simply animate the launch of your application, so it makes sense to skip everything that is inside Frame.ContentTransitions .

You might ask, but Frame.ContentTransitions always null !

Here is one script that will not be null . Try creating your own Frame style with some default ContentTransitions , and instead

 rootFrame = new Frame(); 

do

 rootFrame = new Frame { Style = (Style)App.Current.Resources["MyFrame"] }; 

This time you will see that the code goes into the if , because ContentTransitions no longer null .

+4
source share

Remove rootFrame.Navigated += this.RootFrame_FirstNavigated;

And replace rootFrame.ContentTransitions = null;

rootFrame.ContentTransitions = new TransitionCollection();

To indicate a transition to the use of each page:

 <Page.Transitions> <TransitionCollection> <NavigationThemeTransition /> </TransitionCollection> </Page.Transitions> 
+3
source share

All Articles