Application.OnLaunched method

Applies to Windows and Windows Phone

Invoked when the application is launched. Override this method to perform application initialization and to display initial content in the associated Window.

Syntax


protected:
virtual void OnLaunched(
  LaunchActivatedEventArgs^ args
)

Parameters

args

Type: LaunchActivatedEventArgs

Event data for the event.

Remarks

Override the OnLaunched method to perform any general app initialization that should occur only when the user launches your app normally (for example, by tapping the app tile). For info on other kinds of activation, see OnActivated. Specific activation kinds sometimes have a specific override, also a virtual method on Application. For example, OnFileActivated is invoked for any core Activated event on the Application if the ActivationKind is File.

The starting project templates include a basic implementation for OnLaunched. The implementation sets the initial root visual for the application by setting Window.Current.Content to a new instance of the class defined by the project template's MainPage XAML/code-behind pair.

All Application overrides involved in an activation scenario should call Window.Activate in their implementations.

For example code of overrides of OnLaunched, create a new app project and examine the template-created code in the app.xaml code-behind.

Note  The app.xaml code-behind from some project templates reference APIs in a SuspensionManager helper class. In this case, the OnLaunched override is asynchronous, because some of the SuspensionManager API it calls is asynchronous. For more info, see Minimize startup time.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml
Windows::UI::Xaml [C++]

Metadata

Windows.winmd

See also

Application
Launching and resuming apps

 

 

Show:
© 2014 Microsoft