1
I need to be clicked on the Back button of the Smartphone to be returned to the previous page.
Note: If possible do not use Navigation to not have the bar up there.
1
I need to be clicked on the Back button of the Smartphone to be returned to the previous page.
Note: If possible do not use Navigation to not have the bar up there.
1
Back a page by clicking the button ← is already the native behavior of Xamarin when you are navigating between pages, unless you have overwritten the Onbackbuttonpressed event for some reason and are returning true
in that method.
To enable this behavior you must use a navigation stack (controls provided in the interface INavigation
and implemented by NavigationPage
). You are probably not creating this stack properly.
When the page that is on display is already the root page of the stack (or the MainPage
application), the back button really takes the app to the background.
If your problem with the NavigationPage
for only the top bar, you can disable its display:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="App.Views.MyPage"
NavigationPage.HasNavigationBar="False">
</ContentPage>
Or in the code c# of the page:
NavigationPage.SetHasNavigationBar(this, false);
Thanks, great tips, I didn’t know it was possible to disable the Navigationpage bar.
Browser other questions tagged xamarin xamarin-forms xamarin.android
You are not signed in. Login or sign up in order to post.
In my app when I click to return it closes the application leaving it in the background. I searched in my project 'Onbackbuttonpressed' and nowhere is it being used.
– Deivid Souza
Damn life, I tested here and found out the following, if I use the
Navigation.PushAsync(new Page1());
Physical back really works, but I’m using by default theApp.Current.MainPage = new Login();
, how can I proceed without having to join Navigation?– Deivid Souza
Very grateful for the instruction @Diego
– Deivid Souza
@Diego, how about I ask you to answer my question so I can give you a like? I believe that within this community is important, I can’t do that in a comment.
– Deivid Souza