Reputation: 3
await Shell.Current.GoToAsync("HabeasData");
NavigationPage.SetHasBackButton(this, false);
InitializeComponent();
<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" >
But, it does not work, keep showing the back button.
Xamarin.Forms is updated.
I would greatly appreciate the help.
Upvotes: 0
Views: 2601
Reputation: 9234
NavigationPage.SetHasBackButton(this, false);
is not worked in Shell
You can use Shell.NavBarIsVisible="False"
in the ContentPage
like following code.
<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>
Here is related article about it.
If you still want to keep the title bar and hide the back button. you can add a custom navigation bar with your stack layout. Or use following code and add a transparent png like following GIF.
Here is code.
<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>
Here is transparent png.
Upvotes: 5