简体   繁体   中英

Xamarin Tabbed Page Content Other than Tab

Quick question,

In Xamarin Forms, when using a Tabbed Page, is there any way for there to be content that remains static between the tabs (other than the tabbar itself)?

For example, if I have a TabbedPage with 3 children (say Page1 , Page2 and Page3 ), can I add other children to TabbedPage that are not a part of the tab itself, but elsewhere, and stay there between tabs?

My use for this is I have 3 tabs in my TabbedPage , which is are at the bottom of the page. I would like a settings button in the top-right of each page, without having to create the same content multiple times in each page that is a child of the TabbedPage .

<TabbedPage xlmns="...>
    [Content Here that remains between all tabs, but not a part of the tabbar itself]
    <local:Page1>
    <local:Page2>
    <local:Page3>
</TabbedPage>

Is there some way of doing this easily? Or is there some other method? Thanks for any help.

I would like a settings button in the top-right of each page, without having to create the same content multiple times in each page that is a child of the TabbedPage.

An easy way is using custom control as model. Add the custom control, the button would show in every tabbed pages(page1, page2, page3). If you want to more change on the button, change the custom model, all the changes would show in pages.

Custom Control: ButtonModel

<Button x:Name="btnModel" Text="Button" HorizontalOptions="EndAndExpand" Margin="4,0,8,0"></Button>

Add this in Page1, Page2, Page3

<local:ButtonModel ></local:ButtonModel>

在此处输入图像描述

There are a few methods of fixing this. One of these is outlined in another comment very well, however I found that the Xamarin Forms 'Pure' tabs fitted my needs better. https://www.sharpnado.com/pure-xamarin-forms-tabs/ It was relatively intuitive once I got my head round it and handles integration with mvvm rather well. The tabs need nod span the entire page (other than the tabbar) which is exactly what I wanted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM