Windows 10 UAP 后退按钮 [英] Windows 10 UAP back button

查看:27
本文介绍了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 后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆