Xamarin 表单 UWP AppViewBackButtonVisibility.Collapsed 似乎不起作用



我正在使用Xamarin Forms 3.6。我想在 UWP 应用中隐藏后退按钮。在UWP App.xaml中.cs我添加了OnLaunced。

SystemNavigationManager
     .GetForCurrentView()
     .AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;

我还将其添加到每个 ContentPage(使用依赖注入(,以便在每个页面的构造函数中运行上述代码。

每个内容页面,我还添加了:

NavigationPage.SetHasNavigationBar(this, false);

我似乎总是在 UWP 的标题栏中获得后退按钮。Xamarin Forms UWP 中的任何想法如何隐藏并保持隐藏后退按钮?

根据您的要求,请在要隐藏后退按钮的页面中调用SetHasBackButton静态方法,如下所示。

public ItemDetailPage(ItemDetailViewModel viewModel)
{
    InitializeComponent();
    NavigationPage.SetHasBackButton(this, false);
    BindingContext = this.viewModel = viewModel;
}

最新更新