我有一个ContentPage,它作为ShellContent分配给Xamarin.Forms.Shell类,并要求在ContentPage的导航栏中显示back按钮。
所关注的ContentPage的XAML源代码如下:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="UI_test.TestPage">
<Shell.NavBarIsVisible>True</Shell.NavBarIsVisible>
<Shell.BackButtonBehavior>
<BackButtonBehavior IsEnabled="True" />
</Shell.BackButtonBehavior>
<Shell.FlyoutBehavior>Disabled</Shell.FlyoutBehavior>
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
</StackLayout>
</ContentPage.Content>
</ContentPage>我发现为<BackButtonBehavior>标记的属性TextOverride和IconOverride赋一个自定义值将显示back按钮,但我正在寻找一种方法来显示平台的默认back按钮(而不是自定义按钮),因为上面的ContentPage在其导航栏中不显示为back按钮,如下面的屏幕截图所示。

提前谢谢。
发布于 2021-04-25 18:53:49
你的项目似乎只包含一个页面,如果没有导航,它就不会出现,这是有意义的。如果您使用Shell.GotoAsync(..)或Shell.Navigation.PushAsync(..)导航到另一个页面,它将出现(默认的原生后退按钮),允许返回到导航堆栈中的上一个页面。
https://stackoverflow.com/questions/67250987
复制相似问题