且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Windows 10 Universal Apps UWP上的覆盖关闭框

更新时间:2023-02-01 17:59:28

注释正确。当前没有常规的商店应用程序可以执行此操作。请查看此功能:



Windows.UI.Core.Preview.SystemNavigationManagerPreview类提供了一个CloseRequested事件,应用程序可以将其标记为已处理。为了使事件正常进行,应用程序将需要声明受限制的'confirmAppClose'功能,具体如下:
https://docs.microsoft.com/zh-cn/windows/uwp/packaging/app-capability-declarations



请让我们知道您的反馈。



感谢
Stefan Wick-Windows Developer Platform


I'm trying to prevent the app from being closed by clicking the Close box on the App Window. For example, having a text editor with unsaved changes, upon pressing Close Box, I would first display, "Do you want to save changes before exiting?"

How can I detect app wanting to close and prevent that from happening?

I'm using C++, and this needs to be for Windows 10 Universal Apps UWP. I already know how to do this for Win32.

The comments are correct. There is currently no way for a regular Store app to do this.

However, with the Creators Update (and corresponding SDK) we have included a preview API that you can now check out for this functionality:

The Windows.UI.Core.Preview.SystemNavigationManagerPreview class provides a CloseRequested event that an app can mark as handled. For the event to work the app will need to declare the restricted 'confirmAppClose' capability per: https://docs.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations

Please let us know your feedback.

Thanks, Stefan Wick - Windows Developer Platform