SplashScreen SplashScreen SplashScreen SplashScreen Class

Provides a dismissal event and image location information for the app's splash screen.

Syntax

Declaration

public sealed class SplashScreenpublic sealed class SplashScreenPublic NotInheritable Class SplashScreen

Remarks

Access this object from your app's activated event handler by using the SplashScreen property on the event object that is passed into your handler.

For JavaScript

Respond to onactivated events in your activated event handler. To learn how to respond to activated events, see App lifecycle.

If you notice a flicker during the transition to your extended splash screen, add onload="" on your tag like this: <img id="extendedSplashImage" src="./windows.applicationmodel.activation/images/splash-sdk.png" alt="Splash screen image" onload="" />. This helps prevent flickering by making the system wait until your image has been rendered before it switches to your extended splash screen.

Additionally, if you use fragment loading to load an extended splash screen page, you may still notice a flicker between when the Windows splash screen is dismissed and when your page is displayed. You see this flicker because fragment loading begins to load your imitation splash screen page asynchronously, before the onactivated event handler finishes executing. You can prevent this unsightly flicker by avoiding the use of fragment loading to load your extended splash screen page (as demonstrated by the Splash screen sample). When your additional loading tasks are complete (also as demonstrated by the Splash screen sample) you can then navigate to your app’s main page. Alternatively, if you wish to continue the use of fragment loading in your extended splash screen page, you can also prevent the flicker by getting an activation deferral and responding to onactivated events asynchronously. Get a deferral for an activated event by calling the @Windows.UI.WebUI.ActivatedOperation.@Windows.UI.WebUI.ActivatedOperation.GetDeferral method.

For C#/C++/VB

Respond to Activated events by overloading the corresponding activated event handler method. For example, use OnLaunched(Windows.ApplicationModel.Activation.LaunchActivatedEventArgs) to respond to ActivationKind activation events. To learn how to respond to activated events, see App lifecycle.

If you notice a flicker during the transition to your extended splash screen, see the Troubleshooting section in Guidelines and checklist for splash screens for help.

The SplashScreen property is available on all Windows.ApplicationModel.Activation classes.

Examples

The Splash screen sample demonstrates how to retrieve a SplashScreen object in its activated event handler, when the app launches.

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
    if (args.PreviousExecutionState != ApplicationExecutionState.Running)
    {
        bool loadState = (args.PreviousExecutionState == ApplicationExecutionState.Terminated);
        ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen, loadState);
        Window.Current.Content = extendedSplash;
    }

    Window.Current.Activate();
}
function activated(eventObject) {
    if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
        // Retrieve splash screen object
        splash = eventObject.detail.splashScreen;

        // Retrieve the window coordinates of the splash screen image.
        SdkSample.coordinates = splash.imageLocation;

        // Register an event handler to be executed when the splash screen has been dismissed.
        splash.addEventListener("dismissed", onSplashScreenDismissed, false);

        // Create and display the extended splash screen using the splash screen object.
        ExtendedSplash.show(splash);

        // Listen for window resize events to reposition the extended splash screen image accordingly.
        // This is important to ensure that the extended splash screen is formatted properly in response to snapping, unsnapping, rotation, etc...
        window.addEventListener("resize", onResize, false);

        // Use setPromise to indicate to the system that the splash screen must not be torn down
        // until after processAll and navigate complete asynchronously.
        eventObject.setPromise(WinJS.UI.processAll().then(function () {
            // Navigate to either the first scenario or to the last running scenario
            // before suspension or termination.
            var url = WinJS.Application.sessionState.lastUrl || scenarios[0].url;
            return WinJS.Navigation.navigate(url);
        }));
    }
}

// Register your activated event handler
WinJS.Application.addEventListener("activated", activated, false);

You can use the object passed to your activated event handler to get information about the activated event. In the example, the object contains information about a ActivationKind activation and is either a WebUILaunchActivatedEventArgs (JavaScript) or a LaunchActivatedEventArgs (C#/C++/VB) object, depending on the programming language. The Kind property on this object lets you distinguish between different types of activation (like ActivationKind or ActivationKind ).

Properties summary

The coordinates of the app's splash screen image relative to the window.

Events summary

Fires when the app's splash screen is dismissed.

Properties

  • ImageLocation
    ImageLocation
    ImageLocation
    ImageLocation

    The coordinates of the app's splash screen image relative to the window.

    public Rect ImageLocation { get; }public Rect ImageLocation { get; }Public ReadOnly Property ImageLocation As Rect

    Property Value

    • The coordinates of the splash screen image relative to the window and scaled for the dots per inch (dpi) of the device.

    Remarks

    You can give your app additional time to load by using this property to help you imitate the splash screen that Windows displays for your app. To learn how, see How to extend the splash screen.

    If no splash screen image is displayed, the location returned is where the image is expected.

Events

  • Dismissed
    Dismissed
    Dismissed
    Dismissed

    Fires when the app's splash screen is dismissed.

    public event TypedEventHandler Dismissedpublic event TypedEventHandler DismissedPublic Event Dismissed

    Remarks

    When the Dismissed event fires, the first view of your app is visible on the user's screen.

    Avoid increasing the time required to load your app by using this event as a trigger to perform loading tasks (like loading network data) and animations.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute

Details

Assembly

Windows.ApplicationModel.Activation.dll