我通过谷歌查找但找不到结果。
我有一个 Shell 设置 Xamarin 表单应用程序。尽管我没有完全使用它的功能,但 xaml 文件中有一个选项卡设置。
我想知道我是否可以在 shellContent 下托管一个内容页面并从 contentPage 添加选项卡。
你想像这个GIF一样实现它吗?
您可以添加 x:名称TabBar
in AppShell.xml
就像这段代码。
<TabBar x:Name="myTabBars">
<Tab Title="Browse" Icon="tab_feed.png">
<ShellContent ContentTemplate="{DataTemplate local:ItemsPage}" />
</Tab>
<Tab Title="About" Icon="tab_about.png">
<ShellContent ContentTemplate="{DataTemplate local:AboutPage}" />
</Tab>
</TabBar>
In the AppShell.xml.cs
,暴露这个标签栏。
public partial class AppShell : Xamarin.Forms.Shell
{
// public static Shell myshell;
public static TabBar mytabbar;
public AppShell()
{
InitializeComponent();
mytabbar = myTabBars;
}
}
使用它在ContentPage
.
private void Button_Clicked(object sender, EventArgs e)
{
ShellSection shell_section = new ShellSection
{
Title = "home",
};
shell_section.Items.Add(new ShellContent() { Content = new HomePage() });
AppShell.mytabbar.Items.Add(shell_section);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)