I am adding a navigation bar using
MainPage = new NavigationPage (new Home ());
Then on my Home.cs
page I do not want to show the navigation bar, it is only for pages that link from this page I want to show the navigation bar. To stop the navigation bar from showing on this page I using the following code at the start of Home.cs
.
NavigationPage.SetHasNavigationBar (this, false);
From here when using Navigation.Push.Async
to go to another page I get a "jump" (movement?) at the bottom of Home.cs
. Its like it adds on the height for the navigation bar on the next page.
On iOS it causes the obvious jump if you set the background color on Home.cs
to anything but white.
On Android it seems to only cause this "jump" when navigating back to the Home.cs
page.
This is the code I am using to push to the next page.
btn.Clicked += async (sender, e) => await Navigation.PushAsync (new TestPage ());
I have tried to remove all padding.margins from the pages but this has not helped. As I started a new project to test this there isn't anything else for me to change so I cannot think of any other changes that would solve this.
Gif below: Tried to show the jump in this gif
Note: Keep an eye on the Home.cs
(Grey) page.
NavigatonBar is visible. Sorry, something went wrong. We have updated to the latest version of Xamarin Forms (2.5.0.122203) but we still have the same error with the navigation bar. NavigationPage.SetHasNavigationBar (detailContent, false);
Go to App.xaml.cs and after InitializeComponent (); you have to declare your navigation page like this. And by clicking on the "Next Page" button, you are navigated to the next page. What if you want to set your own Back button on Next Page?
And on its click-event handler, the code looks like the following. "NextPage" is the name of second page declared in this application. In this application, you have to make two pages - Main page and Second page. Go to App.xaml.cs and after InitializeComponent (); you have to declare your navigation page like this.
If we downgrade Xamarin.Forms to 2.3.2.127, it is working as we want, navigation bar is hidden from the begining and we can show popover menu when we want: Thank you. Sorry, something went wrong. Please upload a short sample so we can look at it.
Alternative work around
I my situation I came from a SpringBoard without a navigationbar. So what I did when going to a ContentPage with navigation bar was to Hide before and Show the navigationbar after the PushAsync.
NavigationPage.SetHasNavigationBar(page, false);
await Navigation.PushAsync(page);
NavigationPage.SetHasNavigationBar(page, true);
Not sure if this is a neat solution, but at least it gets rid of the jumping effect. As side effect it makes the navigationbar slide in from the top that looks more like a well thought UI animation then jumping content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With