Monday, 27 January 2014

Prism for the Windows Runtime now supports extended splash screens

One of the new features of Prism for the Windows Runtime for Windows 8.1 is the introduction of support for displaying an extended splash screen that imitates the splash screen displayed by Windows. If an app needs more time to prepare its UI or load network data, you can use an extended splash screen to display a message to the user as the app completes those tasks. For more info about extended splash screens, see How to extend the splash screen and Guidelines for splash screens.

Prism for the Windows Runtime defines an ExtendedSplashScreenFactory property in the MvvmAppBase class. The MvvmAppBase class will check this property during app startup, and if it’s defined it will show the extended splash screen. Therefore, the property should be set to a delegate that returns the app’s extended splash screen.

this.ExtendedSplashScreenFactory = (splashscreen) => new ExtendedSplashScreen(splashscreen);
When an app is launched the system passes splash screen information to the app’s launch activation event handler. This information is used to correctly position the image on the extended splash screen page over the splash screen image displayed by Windows. In a Prism app the app’s launch activation event handler is in the OnLaunched method in the MvvmAppBase class. This method in turn calls the InitializeFrameAsync method in the same class, passing in the launch activation event arguments.
rootFrame = new Frame();
if (ExtendedSplashScreenFactory != null)
    Page extendedSplashScreen = this.ExtendedSplashScreenFactory.Invoke(args.SplashScreen);
    rootFrame.Content = extendedSplashScreen;

Inside the InitializeFrameAsync method, if the ExtendedSplashScreenFactory property is defined the factory will create the extended splash screen page and place it in the Frame for display, before continuing with further initialization. This approach allows the extended splash screen to be displayed without performing a navigation operation, ensuring that it will not form part of the app's navigation history.

For more information, including how to create the extended splash screen, how to correctly position the extended splashscreen, and a full downloadable code example, see Extended splash screen Quickstart for Windows Store apps using C#, XAML, and Prism.

No comments:

Post a Comment