[英]How to know Back Button exist on Windows Devices - Hardware/Software - Windows 10 Desktop/Mobile App - C#
I need to check whether a particular Windows device that runs my application have the back button, either on the device's hardware or in software (Windows 10 in tablet mode). 我需要检查运行我的应用程序的特定Windows设备在设备的硬件还是软件(平板电脑模式下为Windows 10)上是否具有后退按钮。
Someone can help me? 有人可以帮我吗? Thanks
谢谢
For the hardware back button, you can easily check it using ApiInformation.IsTypePresent method. 对于硬件后退按钮,可以使用ApiInformation.IsTypePresent方法轻松地对其进行检查。
public MainPage()
{
this.InitializeComponent();
bool isHardwareButtonsAPIPresent =
Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons");
if(isHardwareButtonsAPIPresent)
{
// add Windows Mobile extenstions for UWP
Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
}
}
private void HardwareButtons_BackPressed(object sender, Windows.Phone.UI.Input.BackPressedEventArgs e)
{
// hareware button pressed
}
According to MSDN the back button should be always present for: Phone, Tablet, Surface Hub. 根据MSDN ,后退按钮应始终存在于:电话,平板电脑,Surface Hub。
As for Desktop/Laptop software button in the title bar of the app can be enabled/disabled. 至于桌面/笔记本电脑软件,可以在应用程序的标题栏中启用/禁用按钮。 You can check if it's visible by getting a property AppViewBackButtonVisibility :
您可以通过获取属性AppViewBackButtonVisibility来检查它是否可见:
bool isSoftwareButton = SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility == AppViewBackButtonVisibility.Visible;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.