簡體   English   中英

Xamarin.Forms Shell 選項卡僅顯示列表中的最后一個選項卡

[英]Xamarin.Forms Shell Tabs only showing last Tab in the list

我正在將現有代碼遷移到 Xamarin Forms 4.0 Shell ,以前我使用的是TabbedPage但現在我想使用Shell Tabs。

下面是遷移后的代碼。 我注意到它只顯示一個頂部選項卡,其中包含列表中的最后一個條目。 就我而言,它僅顯示 Tab2。

<Shell xmlns="http://xamarin.com/schemas/2014/forms"
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
      xmlns:views="clr-namespace:App.Views.Tabs;assembly=App"
      x:Class="App.Views.AppShell"
      x:Name="self">
  <TabBar>
       <Tab>
            <ShellContent>
              <views:Tab1Page BindingContext="{x:Reference self}" Title="Tab1" />
              <views:Tab2Page BindingContext="{x:Reference self}" Title="Tab2"/>
            </ShellContent>
        </Tab>
   </TabBar>
   
</Shell>

嘗試使用以下代碼:

<Shell>
...   
   <Tab>
        <ShellContent Title="Tab1">  <!-- title in the tab -->
            <views:Tab1Page} Title="Tab1" BindingContext="{x:Reference self}"/>
                        <!-- Title in the navigation bar -->
        </ShellContent>
        
        <ShellContent Title="Tab2">
            <views:Tab2Page} Title="Tab2" BindingContext="{x:Reference self}"/>
        </ShellContent>
    </Tab>
...
</Shell>

微軟文檔

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/tabs

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM