我正在开发一个 Xamarin Forms 4.8 版本的应用程序,带有侧边菜单(Flyout)和底部Tabbar
使用 Shell 功能。我的侧边菜单有 4 个项目,底部Tabbar
有 5 个项目。两者都有不同的项目。Tabbar
我的应用程序周围总是需要有这样 5 个项目的底部。当我单击菜单内的任何项目时,底部Tabbar
项目将替换为侧菜单项。我不知道为什么。
我的 AppShell.xaml 页面如下所示,
<Shell xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MyApp.Views"
xmlns:localHome="clr-namespace:MyApp.Views.Home"
xmlns:localOnlineStore="clr-namespace:MyApp.Views.OnlineStores"
xmlns:localBooks="clr-namespace:MyApp.Views.BookList"
xmlns:localUniforms="clr-namespace:MyApp.Views.Uniforms"
xmlns:localUser="clr-namespace:MyApp.Views.User"
xmlns:localMyAccount="clr-namespace:MyApp.Views.MyAccount"
xmlns:localCart="clr-namespace:MyApp.Views.Cart"
xmlns:flyouthead="clr-namespace:MyApp"
xmlns:controls="clr-namespace:MyApp.Renderer;assembly=MyApp"
Title="MyApp"
x:Class="MyApp.AppShell"
FlyoutBehavior="Flyout"
FlyoutHeaderBehavior="Fixed"
FlyoutBackgroundColor="#011948">
<Shell.Resources>
<ResourceDictionary>
<Color x:Key="NavigationPrimary">#011948</Color>
...
...
</ResourceDictionary>
</Shell.Resources>
<Shell.FlyoutHeader> ... </Shell.FlyoutHeader>
<Shell.ItemTemplate> ... </Shell.ItemTemplate>
<Shell.MenuItemTemplate> ... </Shell.MenuItemTemplate>
<TabBar>
<Tab Title="Home"
Icon="ic_home">
<ShellContent Route="HomePage" Shell.TabBarBackgroundColor="{StaticResource NavigationPrimary}" ContentTemplate="{DataTemplate localHome:HomePage}" />
</Tab>
<Tab Title="Books"
Icon="ic_book">
<ShellContent Route="ItemsPage" ContentTemplate="{DataTemplate local:ItemsPage}" />
</Tab>
<Tab Title="Cart"
Icon="ic_cart">
<ShellContent Route="AboutPage" ContentTemplate="{DataTemplate local:AboutPage}" />
</Tab>
<Tab Title="Uniforms"
Icon="ic_uniform">
<ShellContent Route="UniformsPage" ContentTemplate="{DataTemplate localUniforms:UniformsPage}" />
</Tab>
<Tab Title="Profile"
Icon="ic_profile">
<ShellContent Route="MyProfilePage" ContentTemplate="{DataTemplate localMyAccount:MyProfilePage}" />
</Tab>
</TabBar>
<FlyoutItem FlyoutDisplayOptions="AsMultipleItems">
<ShellContent Title="Online Store" Icon="ic_online_store" ContentTemplate="{DataTemplate localOnlineStore:OnlineStorePage}" />
<ShellContent Title="About Us" Icon="ic_about_us" ContentTemplate="{DataTemplate localHome:AboutUsPage}" />
<ShellContent Title="Contact Us" Icon="ic_contact_us" ContentTemplate="{DataTemplate localHome:ContactUsPage}" />
<ShellContent Title="Sign In" Icon="ic_login" Route="LoginPage" ContentTemplate="{DataTemplate localUser:LoginPage}" />
</FlyoutItem>
</Shell>
当我在 Android Emulator 中运行时,我的底部标签栏如下图所示
Flyout 中的侧边菜单如下
当我单击菜单内的项目时,页面呈现如下
在这里,底部Tabbar
项目被替换为侧菜单项。