Andrei Rînea
Andrei Rînea

Reputation: 20780

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

Upvotes: 3

Views: 6540

Answers (1)

Timo Salomäki
Timo Salomäki

Reputation: 7189

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.

Upvotes: 6

Related Questions