Windows 10 Universal Apps UWP上的覆盖关闭框 [英] Override Close Box on Windows 10 Universal Apps UWP

查看:108
本文介绍了Windows 10 Universal Apps UWP上的覆盖关闭框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过单击应用程序窗口上的关闭框来防止关闭该应用程序。
例如,如果有一个文本编辑器具有未保存的更改,则在按下关闭框时,我会首先显示您要在退出前保存更改吗?


如何我可以检测到要关闭的应用程序并防止发生这种情况吗?


我使用的是C ++,这需要用于Windows 10 Universal Apps UWP。
我已经知道如何在Win32上执行此操作。

解决方案

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



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

这篇关于Windows 10 Universal Apps UWP上的覆盖关闭框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆