gpt4 book ai didi

c# - Windows 10 UAP 后退按钮

转载 作者:IT王子 更新时间:2023-10-29 04:33:53 26 4
gpt4 key购买 nike

我将如何处理 Windows Mobile 10 的后退按钮和 Windows 10 平板电脑模式的后退按钮?我一直在到处寻找,但找不到任何例子。

最佳答案

本主题是 Guide to Universal Windows Platform apps 中使用的示例之一.我强烈建议您在开始使用通用应用程序时阅读该内容。

对于页眉上的按钮,使用 Windows.UI.Core.SystemNavigationManager 并设置 AppViewBackButtonVisibility 属性以显示或隐藏按钮并处理 BackRequested 事件以执行导航。

Windows.UI.Core.SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += (s,a) =>
{
Debug.WriteLine("BackRequested");
if (Frame.CanGoBack)
{
Frame.GoBack();
a.Handled = true;
}
}

您可以像在 Windows Phone 8.1 中一样连接硬件后退按钮,但您应该检查 PhoneContract(或单独的类和方法)以确保它存在:

if (ApiInformation.IsApiContractPresent ("Windows.Phone.PhoneContract", 1, 0)) {  
Windows.Phone.UI.Input.HardwareButtons.BackPressed += (s, a) =>
{
Debug.WriteLine("BackPressed");
if (Frame.CanGoBack)
{
Frame.GoBack();
a.Handled = true;
}
};
}

关于c# - Windows 10 UAP 后退按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30597585/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com