Fixing Back Behaviour and Navigation Button in Xamarin Forms with BuildIt.Lifecycle

There were two issues that I identified in my post, Using BuildIt.Lifecycle with Xamarin Forms, which were to do with the navigation between pages

1. The back operation actually did a forward navigation to a new page

2. The navigation button was always showing that there was a previous page, even if there wasn’t

The first issue was fixed with an update to the BuildIt.Lifecycle.XForms library which picks up on the IsNewState flag during state transition to determine whether to do a forward navigation (ie a PushAsync) or a backward navigation (ie a PopAsync).

The second issue was fixed by looking at the Navigation.NavigationStack and based on whether there were any entries in there, toggle whether the navigation bar is shown. The following would hide the navigation bar (it’s a static method on the NavigationPage class).

NavigationPage.SetHasNavigationBar(NavigationRoot, false);

Leave a comment