dotnet maui 如何隐藏桌面上的后退按钮?

Jos*_*hlo 4 maui .net-maui maui-windows

我试图隐藏桌面上图像中显示的后退按钮,但无论我尝试什么,它都会继续显示。

我努力了

<Shell.BackButtonBehavior>
    <BackButtonBehavior IsVisible="False" IsEnabled="False" />
</Shell.BackButtonBehavior>
Run Code Online (Sandbox Code Playgroud)

我已经尝试遵循这篇文章为什么后退按钮隐藏在毛伊岛?

我的导航是这样完成的await Shell.Current.GoToAsync(new ShellNavigationState(location), false);

我错过了什么吗?

在此输入图像描述

Cod*_*ian 11

This technique (the code in your question), added within the <ContentPage ... > declaration at the top of the xaml:

<Shell.BackButtonBehavior>
    <BackButtonBehavior IsVisible="False" IsEnabled="False" />
</Shell.BackButtonBehavior>
Run Code Online (Sandbox Code Playgroud)

seems to work when using the Shell to activate pages in C# codebehind (often in the BindingSource e.g., viewmodel):

await Shell.Current.GoToAsync($"{nameof(MyContentPage)}");
Run Code Online (Sandbox Code Playgroud)

Adding this within the <ContentPage ...> declaration at the top of the xaml:

NavigationPage.HasBackButton="false"
Run Code Online (Sandbox Code Playgroud)

seems to be applicable when using the push/pop within a NavigationPage:

await Navigation.PushAsync(new DetailsPage());
Run Code Online (Sandbox Code Playgroud)

I don't use the Navigation.PushAsync. My app requires very specific navigation based on current data state, so a stack doesn't work for me. I have verified setting the Shell.BackButtonBehavior (in the very code you provided) works in my case because I am activating pages via

await Shell.Current.GoToAsync
Run Code Online (Sandbox Code Playgroud)