WindowActivatedEventHandler 代理人

定義

表示將處理 Activated 事件的方法。

public delegate void WindowActivatedEventHandler(Platform::Object ^ sender, WindowActivatedEventArgs ^ e);
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(402809672, 34329, 19579, 181, 52, 206, 212, 93, 157, 226, 25)]
class WindowActivatedEventHandler : MulticastDelegate
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Guid(402809672, 34329, 19579, 181, 52, 206, 212, 93, 157, 226, 25)]
public delegate void WindowActivatedEventHandler(object sender, WindowActivatedEventArgs e);
Public Delegate Sub WindowActivatedEventHandler(sender As Object, e As WindowActivatedEventArgs)

參數

sender
Object

Platform::Object

IInspectable

附加處理常式的物件。

e
WindowActivatedEventArgs

事件的事件資料。

屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

下列程式碼範例示範此事件的一般使用模式。

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);
    }
}

備註

當系統已啟動或停用 Window 時,就會發生此事件。 應用程式可以藉由檢查WindowActivatedEventArgs.WindowActivationState屬性來判斷Window啟用的狀態。 視窗可以在畫面上顯示,但無法作用中。 此外,如果系統的任何其他部分會離開視窗,就會發生此事件。 這可能會因為使用者互動或程式碼而發生, 而 WindowActivationState 將會指出已採取哪一個動作。

Window 啟用相反的應用程式啟用有自己的 Activated 事件。 如需詳細資訊,請參閱 OnActivated處理應用程式啟用

適用於

另請參閱