xaml - 如何将外壳上部标签设置为全宽
问题描述
我正在使用 Xamarin.forms 5.0 和Shell
.
我的 XAML 代码是
<TabBar Route="Root">
<Tab x:Name="NewsListPageTab" Title="News" Route="NewsListPage">
<Tab.Icon>
<FontImageSource FontFamily="{StaticResource FaRegular}" Glyph="{x:Static utils:FontAwesomeIcons.Newspaper}" />
</Tab.Icon>
<ShellContent ContentTemplate="{DataTemplate pages:NewsListPage}" Title="News1">
<ShellContent.Icon>
<FontImageSource
FontFamily="{StaticResource FaRegular}"
Glyph="{x:Static utils:FontAwesomeIcons.BadgePercent}">
</FontImageSource>
</ShellContent.Icon>
</ShellContent>
<ShellContent ContentTemplate="{DataTemplate pages:NewsListPage}" Title="News2">
<ShellContent.Icon>
<FontImageSource
FontFamily="{StaticResource FaRegular}"
Glyph="{x:Static utils:FontAwesomeIcons.BadgePercent}">
</FontImageSource>
</ShellContent.Icon>
</ShellContent>
</Tab>
</TabBar>
我正在尝试创建的整体外观就像这个图像。
请问如何将图标添加到内部选项卡并在应用程序外壳中使它们全宽?
解决方案
我找到了一个简单的解决方案:我们可以将 TabbedPages 与代表我们需要的选项卡的页面一起使用,而不是使用 ShellContent 作为上部选项卡。
<Tab Title="ُShop" Route="CompaniesTabs">
<ShellContent ContentTemplate="{DataTemplate retailer:CompaniesTabs}" />
</Tab>
TabbedPage 代码如下:
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Retailer.CompaniesTabs">
<retailer:CompaniesStatusPage Title="Store1" />
<retailer:CompaniesListPage Title="Store3" />
<retailer:CompaniesFavoritePage Title="Store3" />
</TabbedPage>
而已。
推荐阅读
- neo4j - 为什么一个适度的 MATCH 和 CREATE 查询会在 Neo4j 浏览器中旋转?
- angular - 如何将数组作为数据从角度发送到快递路由器?
- pycaret - PyCaret predict_model() 方法失败并出现 Pipeline not Found 错误
- python - 如果下一个文件已经完成,则 luigi 任务失败
- c++ - 关于return语句出现异常的问题
- asp.net-core - 从 api 向 ms 团队 bot 发送消息
- javascript - 哪些 HTML 元素意味着分词?
- hyperledger-fabric - hyperledger fabric2.2中数据库为leveldb时没有创建容器
- javascript - 如何在javascript中验证文件名和文件扩展名
- sql-server - MS Access ODBC 通过 Internet 连接到 SQL Server 速度慢