【发布时间】:2015-10-07 14:18:16
【问题描述】:
我需要检查运行我的应用程序的特定 Windows 设备是否具有后退按钮,无论是在设备的硬件上还是在软件中(平板电脑模式下的 Windows 10)。
有人可以帮助我吗? 谢谢
【问题讨论】:
-
您想知道是否有硬件/系统提供了一个,还是要强制系统为您绘制一个?你最终想要做什么?
标签: c# windows-10 back uwp windows-10-mobile
我需要检查运行我的应用程序的特定 Windows 设备是否具有后退按钮,无论是在设备的硬件上还是在软件中(平板电脑模式下的 Windows 10)。
有人可以帮助我吗? 谢谢
【问题讨论】:
标签: c# windows-10 back uwp windows-10-mobile
对于硬件返回按钮,您可以使用 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
}
【讨论】:
根据MSDN,后退按钮应始终存在于:手机、平板电脑、Surface Hub。
至于桌面/笔记本电脑软件按钮在应用程序的标题栏中可以启用/禁用。你可以通过获取属性AppViewBackButtonVisibility来检查它是否可见:
bool isSoftwareButton = SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility == AppViewBackButtonVisibility.Visible;
【讨论】: