Windows 10 UAP back button(Windows 10 UAP 后退按钮)
问题描述
如何处理 windows mobile 10 的后退按钮和 windows 10 平板模式的后退按钮?我一直在到处寻找,但找不到任何例子.
How would I handle the back button for windows mobile 10 and the back button for windows 10 tablet mode? I've been looking everywhere but can't find any examples for it.
推荐答案
本主题是 通用 Windows 平台应用指南.我强烈建议在开始使用通用应用程序时阅读.
This topic is one of the examples used in the Guide to Universal Windows Platform apps . I strongly suggest reading that when getting started with Universal apps.
对于页眉上的按钮,使用 Windows.UI.Core.SystemNavigationManager 并设置 AppViewBackButtonVisibility 属性以显示或隐藏按钮并处理 BackRequested 事件以执行导航.
For the button on the page header use Windows.UI.Core.SystemNavigationManager and set the AppViewBackButtonVisibility property to show or hide the button and handle the BackRequested event to perform the navigation.
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(或单个类和方法)以确保它存在:
You wire up the hardware back button the same as you do in Windows Phone 8.1, but you should check for the PhoneContract (or the individual class and method) to make sure it is there:
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;
}
};
}
这篇关于Windows 10 UAP 后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Windows 10 UAP 后退按钮
基础教程推荐
- SSE 浮点算术是否可重现? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 如何激活MC67中的红灯 2022-01-01
- 将 XML 转换为通用列表 2022-01-01