Application.OnLaunched(LaunchActivatedEventArgs) Method

Definition

Invoked when the application is launched. Override this method to perform application initialization and to create a new window.

protected:
 virtual void OnLaunched(LaunchActivatedEventArgs ^ args) = OnLaunched;
void OnLaunched(LaunchActivatedEventArgs const& args);
protected virtual void OnLaunched(LaunchActivatedEventArgs args);
function onLaunched(args)
Protected Overridable Sub OnLaunched (args As LaunchActivatedEventArgs)

Parameters

Examples

Use OnLaunched to create and activate the main window. (This code is provided by the Visual Studio project templates when you create a WinUI 3 app.)

private Window m_window;

protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
    m_window = new MainWindow();
    m_window.Activate();
}

Applies to

See also