Windows desktop applications
Collapse the table of content
Expand the table of content
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.

WindowActivatedEventHandler delegate

Represents the method that will handle the Activated event.

Syntax


public delegate void WindowActivatedEventHandler(
  object sender, 
  WindowActivatedEventArgs e
)

Parameters

sender

Type: System.Object [.NET] | Platform::Object [C++]

The object where the handler is attached.

e

Type: WindowActivatedEventArgs

Event data for the event.

Remarks

This event occurs when a Window has been activated or deactivated by the system. An app can determine what the status of the Window activation is by checking the WindowActivatedEventArgs.WindowActivationState property. A Window could be visible on screen but not be active. Additionally, if any other parts of the system takes focus away from the window, this event will occur. This could happen as a result of user interaction or code, and the WindowActivationState will indicate which action has taken place.

App activation as opposed to Window activation has its own Activated event. For more info, see OnActivated or Handle app activation.

Examples

The following code example demonstrates a typical usage pattern for this event.


void Current_Activated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
{
    if (e.WindowActivationState == 
        Windows.UI.Core.CoreWindowActivationState.Deactivated)
    {
        // Show the "paused" UI. 
        VisualStateManager.GoToState(this, "PauseUI", false);
    }
    else if (e.WindowActivationState == 
        Windows.UI.Core.CoreWindowActivationState.PointerActivated)
    {
        // Show the "active" UI. 
        VisualStateManager.GoToState(this, "ActivateUI", false);
    }
}


Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

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

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

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

Attributes

[Version(0x06020000)]
[WebHostHidden()]

See also

Window

 

 

Show:
© 2016 Microsoft