Samuel Mungy
Samuel Mungy

Reputation: 467

Converting Content Page to Navigation Page in Xamarin

I created a Content Page named MainList.xaml. Now my main page isn't a navigation page since it deals with setting the App up but I want MainList.xaml to be a navigation page. The problem is, when I try:

MainList mainListPage = new NavigationPage(new MainList());

I get the error:

Cannot implicitly convert type 'Xamarin.Forms.NavigationPage' to 'SalApp.views.MainList'

How would I go about converting it into a navigation page? There doesn't seem to be an option to even create a navigation page. In the App.xaml file, I can make MainPage.xaml a navigation page but I don't know why MainList doesn't have the same privilige.

Upvotes: 2

Views: 2067

Answers (1)

Jason
Jason

Reputation: 89082

you're creating an instance of NavigationPage that wraps MainList, to the type returned will be a NavigationPage

NavigationPage navPage = new NavigationPage(new MainList());

Upvotes: 4

Related Questions