SplashScreen クラス

定義

アプリのスプラッシュ スクリーンの無視イベントと画像の場所情報を提供します。

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
継承
Object Platform::Object IInspectable SplashScreen
属性

Windows の要件

デバイス ファミリ
Windows 10 (10.0.10240.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v1.0 で導入)

Splash screen サンプルは、アプリの起動時に、アクティブ化されたイベント ハンドラーで SplashScreen オブジェクトを取得する方法を示しています。

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);

アクティブ化されたイベント ハンドラーに渡された オブジェクトを使用して、アクティブ化されたイベントに関する情報を取得できます。 この例では、 オブジェクトには 起動 のアクティブ化に関する情報が含まれており、プログラミング言語に応じて webUILaunchActivatedEventArgs (JavaScript) または LaunchActivatedEventArgs (C#/C++/VB) オブジェクトです。 このオブジェクトの Kind プロパティを使用すると、さまざまな種類のアクティブ化 ( ActivationKind.launchActivationKind.search など) を区別できます。

注釈

ハンドラーに渡されるイベント オブジェクトの SplashScreen プロパティを使用して、アプリのアクティブ化されたイベント ハンドラーからこのオブジェクトにアクセスします。

JavaScript の場合

アクティブ化されたイベント ハンドラーで、アクティブ化されたイベントに応答します。 アクティブ化されたイベントに応答する方法については、「 アプリのライフサイクル」を参照してください。

拡張スプラッシュ画面への切り替え中にちらつきが発生した場合は、次のように タグを追加onload=""します。 <img id="extendedSplashImage" src="./windows.applicationmodel.activation/images/splash-sdk.png" alt="Splash screen image" onload="" /> これにより、拡張スプラッシュ画面に切り替わる前にイメージがレンダリングされるまでシステムを待機させることで、ちらつきを防ぐことができます。

さらに、フラグメント読み込みを使用して拡張スプラッシュ スクリーン ページを読み込む場合でも、Windows スプラッシュ スクリーンが閉じられたときとページが表示されたときの間にちらつきが発生することがあります。 このちらつきが発生するのは、 非アクティブ化された イベント ハンドラーの実行が完了する前に、フラグメントの読み込みがイミテーション スプラッシュ スクリーン ページの非同期的な読み込みを開始するためです。 この見苦しいちらつきを防ぐには、フラグメントの読み込みを使用して拡張スプラッシュ スクリーン ページを読み込むのを回避します ( スプラッシュ スクリーン サンプルで示すように)。 追加の読み込みタスクが完了したら (スプラッシュ スクリーン サンプルでも示すように)、アプリのメイン ページに移動できます。 または、拡張スプラッシュ スクリーン ページでフラグメント読み込みを引き続き使用する場合は、アクティブ化の遅延を取得し、 アクティブ化された イベントに非同期的に応答することで、ちらつきを防ぐこともできます。 activatedOperation を呼び出して、アクティブ化されたイベントの遅延を取得します。getDeferral メソッド。

C#/C++/VB の場合

対応する アクティブ化イベント ハンドラー メソッドをオーバーロードして、アクティブ化されたイベントに応答します。 たとえば、 OnLaunched を 使用して ActivationKind.Launch アクティブ 化イベントに応答します。 アクティブ化されたイベントに応答する方法については、「 アプリのライフサイクル」を参照してください。

拡張スプラッシュ画面への切り替え中にちらつきが発生する場合は、「 スプラッシュスクリーン (HTML) を拡張する方法 」の「解説」セクションを参照してください。

SplashScreen プロパティは、すべての Windows.ApplicationModel.Activation クラスで使用できます。

プロパティ

ImageLocation

ウィンドウに対するアプリのスプラッシュ スクリーン イメージの座標。

イベント

Dismissed

アプリのスプラッシュ スクリーンが閉じられたときに発生します。

適用対象

こちらもご覧ください