Share via


Window.Activate Method

Definition

Attempts to activate the application window by bringing it to the foreground and setting the input focus to it.

public:
 virtual void Activate() = Activate;
void Activate();
public void Activate();
function activate()
Public Sub Activate ()

Remarks

If you use the default app templates from Microsoft Visual Studio, Window.Activate is part of the initial code in the app.xaml code-behind file. Specifically, Activate is called from the default OnLaunched override. In cases where the template produces a page navigation experience, previous states are detected so that the navigation framework isn't overwritten if it already existed, but Activate is called regardless.

You can modify the default OnLaunched implementation in order to delay calling Activate. You might do this to have all app rendering be complete before the main Window is shown. For example, a delay can be useful to finish loading Image source files in the initial UI. (These load asynchronously and it's impractical to handle ImageOpened from app.xaml code-behind.) On the other hand, delaying the call can create an undesirable user experience if the splash screen is visible for too long.

Applies to

See also