Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a Navigation Bar in Xamarin Forms for iOS?

Is there support in XAML in Xamarin Forms for creating a Navigation Bar for iOS? I searched in all Xamarin support, forums and internet..

At this point I am not convinced that there is support but I really don't want to re-invent the wheel if it's already invented..


Edit:

By navigation bar I mean this thingie:

enter image description here

like image 379
Andrei Rînea Avatar asked Jan 24 '26 17:01

Andrei Rînea


1 Answers

When you create your pages using NavigationPage, Xamarin.Forms automatically creates a navigation bar on iOS. You can also modify quite a few things of the navigation bar, like this:

NavigationPage.SetBackButtonTitle(this, ""); // Empty text
NavigationPage.SetHasBackButton(this, false); // No back button
NavigationPage.SetTitleIcon (this, someIcon); // Set the icon

Take a look at the following article for quite a good explanation of differences between ContentPage and NavigationPage: Xamarin.Forms Pages: ContentPage and NavigationPage

Xamarin's official documentation also covers the navigation quite well: Hierarchial Navigation


Have you set your root page to be of type NavigationPage? In your App class you should have something like

MainPage = new ContentPage(); // etc.

Change it to be something like this

MainPage = new NavigationPage(new FirstPageOfTheApp());
//FirstPageOfTheApp should be of type ContentPage.

So to sum it up, the root page needs to be NavigationPage and all the other pages of type ContentPage.

like image 77
Timo Salomäki Avatar answered Jan 26 '26 05:01

Timo Salomäki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!