level 13
我搜了一下,好像没办法。查了一下msdn的提
这段话有些参考意义:
There is no closing event in Universal Windows apps like Form.FormClosing Event. But if you want to do something before you leaving a page, you can use Page.OnNavigatingFrom method. OnNavigatingFrom can be used to cancel a navigation by setting a Cancel property in the event data from your handler.
And if you want to do something before you closing your app, you can use Application.Suspendingevent. There's no special event to indicate that the user closed the app. After an app has been closed by the user, it's first suspended and then terminated, and enters the NotRunning state. Note that if an app does not return from the suspending event within 5 seconds , Windows assumes that the app has stopped responding and terminates it. For more information at App lifecycle.
1、UWP里面没有Close事件
2、当你关闭应用,会调用Application.Suspending事件,APP挂起,然后被kill掉
(你可以试一下:打开任务管理器看一眼,关闭一个应用后,会在后台短暂停留几秒
你可以参考win10 app 的生命周
关于在应用挂起时保存数据,可以参考MSDN的Suspending API:
注:MSDN关键词搜索:Handle app suspend、Closing event in Universal Windows apps 、Windows 10 universal Windows platform (UWP) app lifecycle
连续超过10次,被百度吞回复,我就不填写链接了,你自己去MSDN查吧
2017年07月26日 08点07分