【问题标题】:remove back button page xamarin xaml删除返回按钮页面 xamarin xaml
【发布时间】:2020-04-28 21:47:49
【问题描述】:
  1. 显示页面: await Shell.Current.GoToAsync("HabeasData");
  2. 在 HabeasData 构造函数中,我输入了以下内容:
     NavigationPage.SetHasBackButton(this, false);
     InitializeComponent();
  1. 我也试试这个:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             Title="Habeasdata"
             x:Class="AppColantaDomicilios.Views.HabeasData"

      NavigationPage.HasBackButton="False" >

但是,它不起作用,继续显示返回按钮。

Xamarin.Forms 已更新。

非常感谢您的帮助。

【问题讨论】:

    标签: xaml xamarin


    【解决方案1】:

    NavigationPage.SetHasBackButton(this, false); 不适用于Shell 您可以在ContentPage 中使用Shell.NavBarIsVisible="False",如下代码所示。

    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:d="http://xamarin.com/schemas/2014/forms/design"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 mc:Ignorable="d"
                Shell.NavBarIsVisible="False"
                 x:Class="App7.Views.Page1">
        <ContentPage.Content>
            <StackLayout>
                <Label Text="Welcome to Xamarin.Forms!"
                    VerticalOptions="CenterAndExpand" 
                    HorizontalOptions="CenterAndExpand" />
            </StackLayout>
        </ContentPage.Content>
    </ContentPage>
    

    这是有关它的相关文章。

    https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/configuration#disable-the-navigation-bar

    如果您仍想保留标题栏并隐藏后退按钮。您可以使用堆栈布局添加自定义导航栏。或者使用下面的代码并添加一个透明的 png 像下面的 GIF。

    这是代码。

    <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:d="http://xamarin.com/schemas/2014/forms/design"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 mc:Ignorable="d"
    
                 x:Class="App7.Views.Page1">
        <Shell.BackButtonBehavior>
            <BackButtonBehavior IsEnabled="False" IconOverride="test.png"
                                 />
        </Shell.BackButtonBehavior>
    
        <ContentPage.Content>
            <StackLayout>
                <Label Text="Welcome to Xamarin.Forms!"
                    VerticalOptions="CenterAndExpand" 
                    HorizontalOptions="CenterAndExpand" />
            </StackLayout>
        </ContentPage.Content>
    </ContentPage>
    

    这是透明的png。

    【讨论】:

    • 这个问题有更新吗?如果回复有帮助,请采纳这个答案(点击这个答案左上角的),对有类似问题的其他人会有所帮助
    猜你喜欢
    • 2020-05-12
    • 2013-04-11
    • 2017-01-09
    • 2010-11-14
    • 1970-01-01
    • 2015-06-29
    • 1970-01-01
    • 2020-09-08
    • 1970-01-01
    相关资源
    最近更新 更多