Megosztás a következőn keresztül:


SplashScreen Class

Definition

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

public ref class SplashScreen sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
class SplashScreen final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public sealed class SplashScreen
Public NotInheritable Class SplashScreen
Inheritance
Object Platform::Object IInspectable SplashScreen
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

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 launch 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.launch or ActivationKind.search).

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 activatedOperation.getDeferral method.

For C#/C++/VB

Respond to Activated events by overloading the corresponding activated event handler method. For example, use OnLaunched to respond to ActivationKind.Launch 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 Remarks section in How to extend the splash screen (HTML) for help.

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

Properties

ImageLocation

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

Events

Dismissed

Fires when the app's splash screen is dismissed.

Applies to

See also