Window.Activated 事件
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
成功激活或停用窗口时发生。
// Register
event_token Activated(TypedEventHandler<IInspectable, WindowActivatedEventArgs const&> const& handler) const;
// Revoke with event_token
void Activated(event_token const* cookie) const;
// Revoke with event_revoker
Window::Activated_revoker Activated(auto_revoke_t, TypedEventHandler<IInspectable, WindowActivatedEventArgs const&> const& handler) const;
public event TypedEventHandler<object,WindowActivatedEventArgs> Activated;
function onActivated(eventArgs) { /* Your code */ }
window.addEventListener("activated", onActivated);
window.removeEventListener("activated", onActivated);
- or -
window.onactivated = onActivated;
Public Custom Event Activated As TypedEventHandler(Of Object, WindowActivatedEventArgs)
事件类型
TypedEventHandler<IInspectable,WindowActivatedEventArgs>
示例
下面的代码示例演示此事件的典型使用模式。
void Window_Activated(object sender, WindowActivatedEventArgs e)
{
if (e.WindowActivationState == WindowActivationState.Deactivated)
{
// Show the "paused" UI.
VisualStateManager.GoToState(this, "PauseUI", false);
}
else if (e.WindowActivationState == WindowActivationState.PointerActivated
|| e.WindowActivationState == WindowActivationState.CodeActivated)
{
// Show the "active" UI.
VisualStateManager.GoToState(this, "ActivateUI", false);
}
}
注解
当 窗口 已激活或停用时,将发生此事件。 可以通过检查 WindowActivationState 属性来确定激活状态Window。
如果系统的任何其他部分将焦点从窗口移开,则会发生此事件。 可以在屏幕上显示 A Window ,但不能处于活动状态。
由于用户交互或代码,窗口激活可能会发生,并且 WindowActivationState 将指示已执行哪些操作。