Update (3 Dec 2014)
I just discovered a way of using animations to 'hide' the OS level turnstile when the app gets loaded the first time.
Three things are required to achieve this -
- The app doesn't have a splash image.
ContentTransitions
is set to null
in your main page's NavigatedTo
handler.
- Create a
PageIn
animation and animate your main page's LayoutRoot
's background color - basically to have it aligned with system background color first and then animate it to whatever color you want in a short amount of time.
You can download a sample from here.
If you have all the code commented out. You would think that the ContentTransitions
should still be null
right? At least that's what I thought.
The answer is no. The ContentTransitions
will later be assigned with a NavigationThemeTransition
.
This might be because in the default Frame
style, there's these lines of code.
<Setter Property="ContentTransitions">
<Setter.Value>
<TransitionCollection>
<NavigationThemeTransition/>
</TransitionCollection>
</Setter.Value>
</Setter>
However, this property of Frame
only gets set very late. If you put a breakpoint in the constructor of your MainPage
. You will see it's still null
. But if you put another breakpoint in the OnNavigatedTo
, finally you will see both this.Frame
and this.Frame.ContentTransitions
with values in them.
What if I uncomment out
rootFrame.ContentTransitions = null;
I guess, in the setter of this property, there's no if (_contentTransitions != null) return;
check, when you set it to null
, there must be something that stops it from getting the default NavigationThemeTransition
, and that's why you don't see the turnstile animation anymore.
However, there's still one animation you will always see no matter what you do.
Try suspending your app by pressing the back or home key and re-activate it. Yes, the turnstile animation is back! Though I think this turnstile animation is different from the ones we disabled in the Frame.ContentTransitions
. Take a look at how an app is launched for the very first time - a splash screen coming up with the turnstile animation. This I believe, is the the same one, and it's probably controlled by the OS.
So, why do they put in this check?
if (rootFrame.ContentTransitions != null)
My guess is because since there's an OS level turnstile animation, if you don't provide a splash screen, the OS will simply animate your app launching so it makes sense to skip whatever is inside the Frame.ContentTransitions
.
You would probably then ask but Frame.ContentTransitions
is always null
!
Here's one scenario that it won't be null
. Try creating a custom Frame
style with some default ContentTransitions
, and instead of
rootFrame = new Frame();
do
rootFrame = new Frame { Style = (Style)App.Current.Resources["MyFrame"] };
This time, you will see the code go into the if
statement as the ContentTransitions
is no longer null
.