Physical return button in Xamarin Forms

1

I need the Smartphone Back button to be returned to the previous page.

Note: If possible do not use Navigation to not have the bar up there.

    
asked by anonymous 17.04.2018 / 20:42

1 answer

1

Returning a page by clicking the ← button is already Xamarin's native behavior when browsing between pages, unless you have overwritten the OnBackButtonPressed event by some reason and is returning true in this method.

To enable this behavior you should use a navigation stack (controls provided in the INavigation interface and implemented by NavigationPage ). You are probably not creating this stack properly.

When the page being displayed is already the stack's root page (or the MainPage of the application), the back button actually takes the app to the background.

If your problem with NavigationPage is only the top bar, you can disable your view:

<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 c # code of the page:

NavigationPage.SetHasNavigationBar(this, false);
    
18.04.2018 / 18:47