Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup a content page of a tabbed page in XAML in Xamarin?

I want to setup a tabbed page with three content pages they are page1, page2 and page3 all of them are content pages. When the program starts I want to show page1 content page with page1 tab selected. They do not follow item template model since they are all different content pages compared to the example showing in the Tabbed Page example @ xamarian.

<TabbedPage.Children>
    <ContentPage Title="Page 1" />
    <ContentPage Title="Page 2" />
    <ContentPage Title="Page 3" />
</TabbedPage.Children>

What property I should set here so that I can point to the content of the associated content page or do I follow tab selecte event and manually call the appropriate content page? I would like to try to do it with XAML as much as possible. Thanks

like image 852
Nair Avatar asked Sep 22 '14 23:09

Nair


People also ask

How do I add a tab page to a content page in Xamarin?

Now, right click on your portable project -> Add -> New item. Then, go to Cross-Platform -> Forms Tabbed Page Xaml (rename it) -> click Add. Now, you will see some code in your tabbed page. A tab page is a parent page that contains multiple pages in it.

Can we add content above tabbed page in Xamarin forms?

We can add the content above or below the tab view component. But it's not possible in xamarin tabbed page.

How do I create a content page in Xamarin?

Xamarin Forms is updated in Android project. For Adding Xaml ContentPage, right click XamFormConPage(Portable) project and select ADD-> NewItem. Select -> CrossPlatform -> FormXamlPage -> Give it a relevant name. Now, XAML Content Page is added to your project.

How do I navigate one page to another page in Xamarin?

Go to Solution Explorer-->Your Project-->Portable-->Right click-->Add-->New Item (Ctrl+Shift+A). Now, select Forms XAML page and give the name (MainPage. xaml). In this step, add another one page, whose name is called SecondPage.


1 Answers

Found the answer here just in case looking for the same question. In my case, I was able to do it in the code behind, but you can do the same in XAML as the post says. One additional thing is, when you add a content page to a tab item and if you want to add title and Icon to it, then you can reference the index of the child and you can set them manually as .Tile and .Icon.

this.Children.Add( new Page1 ());
this.Children[0].Title = "Page 1";
this.Children[1].Icon = "page1.png"
like image 109
Nair Avatar answered Oct 20 '22 17:10

Nair