Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Window.Activate method

Applies to Windows and Windows Phone

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

Syntax


public void Activate()

Parameters

This method has no parameters.

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.

Calling Activate is required for all app activation scenario, not just app launch.

This method is important for the correct operation of an app. If an app does not call Activate on the Current window, and the app is not visible on screen, then the app will be terminated after 15 seconds. If the app or its splash screen is kept on screen there is no time limit, but eventually the app needs to call Activate to progress. Also, certain app contracts extend the time limit.

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.

For secondary windows, you also need to call Activate. Secondary windows are an uncommon scenario for most Windows Store apps using C++, C#, or Visual Basic.

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

Window
Application
OnLaunched
Activated
How to activate an app
Quickstart: Navigating between pages

 

 

Show:
© 2014 Microsoft. All rights reserved.