Ruddy Ruddy - 5 months ago 31
iOS Question

Xamarin.Forms SetHasNavigationBar false causes jump on PushAsync

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.

Answer

After a lot of looking around I have found this to be a bug in Xmarin.Forms. No news on when there will be a fix or any work around.

Please keep an eye on the bug report here:

https://bugzilla.xamarin.com/show_bug.cgi?id=32830


Work Around (ish?)

As a workaround I have stopped the animation from happening at all. Adding false as a second parameter will disable the animation. This doesnt look great but maybe better then seeing the little "jump" problem.

btn.Clicked += async (sender, e) => await Navigation.PushAsync (new TestPage (), false);
Comments