我指的是http://msdn.microsoft.com/en-us/library/windows/apps/hh464925.aspx#app_activation
// App is an Application
public App()
{
this.InitializeComponent();
// Doesn't compile
//this.Activated += OnActivated;
this.Suspending += OnSuspending;
}
protected override void OnActivated(IActivatedEventArgs args)
{
System.Diagnostics.Debug.WriteLine("OnActivated");
}
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
deferral.Complete();
}
注意,OnActivated
永远不会被触发。OnSuspending
将在我退出应用程序大约 30 秒后触发。
如何捕获Activated
事件?奇怪的是我没有在 中找到Activated
事件App
,尽管文档是这样说的。