Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 217
Ruddy Avatar asked Mar 14 '16 09:03

Ruddy


People also ask

Is the navigation bar visible in Xamarin forms?

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);

How to set back button on next page in XAML?

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?

How to create a navigation page using click event in XAML?

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.

What happens if we downgrade Xamarin forms to another version?

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.


Video Answer


1 Answers

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.

like image 154
Jørgen Avatar answered Oct 24 '22 10:10

Jørgen