如何在Template10中将UWP ShellBackButton显示为按钮? [英] How to show the UWP ShellBackButton as a button in Template10?

查看:78
本文介绍了如何在Template10中将UWP ShellBackButton显示为按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Template10的用户控件中将UWP ShellBackButton显示为按钮.

I need to show the UWP ShellBackButton as a button in my user control in Template10.

ShellBackButton是应用程序左上方的后退按钮,但我需要在主屏幕上将其显示为按钮,以便用户可以单击它.

The ShellBackButton is the back button on top left in the application but I need to show this as a button in the main screen so the user can click on it.

我已经对此进行了研究,但是找不到执行该操作的方法.

I have researched this, but could not find how to do this.

App.xaml.cs中有一个属性,用于在左上角显示按钮,即ShowShellBackButton,我想在用户控件视图中将其作为按钮.

There a property in App.xaml.cs to show the button on top left, that is ShowShellBackButton and I want to have this as a button in my user control view.

推荐答案

最后,我完成了这项工作.如果您遇到这种情况,这是可供将来参考的解决方案.

Finally, I got this working. Here is the solution for future reference, if you ever stuck in this situation.

在继承Model10中的ViewModelBase的ViewModel中必须包含以下内容.

The following will need to be inside your ViewModel inheriting the ViewModelBase in Template10.

var nav = Template10.Common.WindowWrapper.Current().NavigationServices.FirstOrDefault();
        var frame = nav.Frame;
        if (frame.CanGoBack)
            frame.GoBack();

您还可以使用CanGoBack属性来使后退按钮可见或不可见.

You can also make it so that the back button is visible or not by using the CanGoBack property.

这篇关于如何在Template10中将UWP ShellBackButton显示为按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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