问题描述
通用应用程序不允许删除或禁用看起来的关闭按钮.我们可以通过全屏来隐藏它.但是当将光标移到它上面时,将标题栏带回来.有没有办法去掉关闭按钮?
原因:我正在处理屏幕时间.允许的时间结束后,我想挡住屏幕.我应该删除关闭按钮,以便用户无法跳过我的应用程序.
删除关闭按钮无济于事.这是工作的一部分.我只是在问如何删除它.
使用当前发布的 API,我们可以自定义标题栏中这三个按钮的颜色.但是没有任何属性或方法可用于禁用或删除这些按钮.
在 UWP 中,我们可以使用
然而,这实际上不会隐藏这些按钮.用户仍然可以最小化或最大化应用程序,并且当指针位于右上角时,他们仍然会看到关闭按钮.
从 Windows 8.1 开始,如果我们希望用户只使用一个应用程序而不执行其他操作(包括关闭应用程序),我们可以使用 Kiosk 模式.有关详细信息,请参阅 在 Windows 8.1 中启用 Kiosk 模式 和 在 Windows 10 专业版、企业版或教育版上设置信息亭.但是,这不符合您的要求,因为您想在允许的时间结束后阻止屏幕.
因此,UWP 可能不是满足您要求的最佳选择.您可以尝试使用经典桌面应用来实现它.
Universal app does not allow to remove or disable the close button it seems. We can hide it by going full screen. But when moving cursor over it, brings title bar back. Is there any way to remove the close button?
Reason : I am working on screen time. After allowed time gets over, I want to block the screen. I should remove close button so that user cant get over my app.
Edit : Removing close button wont help completely. It is a part of work. I am just asking how to remove it.
With current released API, we are able to customize the color of these three buttons in title bar. But there is no property or method could be used to disable or remove these buttons.
In UWP, we can use ApplicationView.TitleBar | titleBar property to get the title bar like following:
ApplicationViewTitleBar titleBar = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar;
This property's type is ApplicationViewTitleBar. It only has several properties that can customize the button's color like:
titleBar.ButtonBackgroundColor = Windows.UI.Colors.White;
titleBar.ButtonForegroundColor = Windows.UI.Colors.White;
titleBar.ButtonHoverBackgroundColor = Windows.UI.Colors.White;
titleBar.ButtonHoverForegroundColor = Windows.UI.Colors.White;
titleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.White;
titleBar.ButtonInactiveForegroundColor = Windows.UI.Colors.White;
titleBar.ButtonPressedBackgroundColor = Windows.UI.Colors.White;
titleBar.ButtonPressedForegroundColor = Windows.UI.Colors.White;
Using these properties may make the close button invisible like:
However this won't actually hide these buttons. Users can still minimize or maximize the app and when the pointer is over the top right corner, they will still see the close button.
From Windows 8.1, if we want users to use only an application and do nothing else including closing the application, we can use Kiosk Mode. For more info, please see Enable Kiosk Mode in Windows 8.1 and Set up a kiosk on Windows 10 Pro, Enterprise, or Education. However this won't meet your requirement as you want to block the screen after allowed time gets over.
So UWP may not be the best choice for your requirement. You may try to implement it with classic desktop apps.
这篇关于从 uwp 应用程序禁用或删除关闭按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!