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 the main window and pass it the first command line argument.

protected override void OnLaunched(MUX.LaunchActivatedEventArgs e)
{
    MainWindow window = new MainWindow();

    if (e.Arguments != null)
    {
        string[] arguments = e.Arguments.Split(' ');
        // Assuming MainWindow' has a public property called FileName 
        window.FileName = arguments[0];
    }

    window.Activate();
}

Remarks

This method is typically created automatically when a project is created. You can then modify it or remove it.

Applies to

See also