c# - 我的面向 Xamarin 的 UWP 应用缺少选项卡
问题描述
我创建了一个简单的 Xamarin 应用程序,其中包含两个页面,每个页面都可以通过选项卡访问,如下所示:
Android 目标工作正常(如上面的屏幕截图所示),所以我现在添加了一个 UWP 目标。问题是 UWP 目标仅显示一页,即没有选项卡,因此无法在两页之间进行选项卡。
如何将选项卡添加到 UWP 应用?请注意,我在创建 UWP 应用程序时使用了选项卡模板。
其他一切都按预期工作(选项卡除外)。
我正在使用 Visual Studio 2017。
这是主页的 XAML:
<ContentPage.ToolbarItems>
<ToolbarItem
Command="{Binding SettingsCommand}"
Text="Settings">
<ToolbarItem.Icon>
<OnPlatform x:TypeArguments="FileImageSource">
<On Platform="iOS, Android" Value="app_settings" />
<On Platform="UWP, WinRT, WinPhone" Value="Assets/app_settings.png" />
</OnPlatform>
</ToolbarItem.Icon>
</ToolbarItem>
</ContentPage.ToolbarItems>
<TabbedPage.Title>
<OnPlatform x:TypeArguments="x:String">
<On Platform="iOS, UWP, WinRT, WinPhone" Value="MyNamespace" />
</OnPlatform>
</TabbedPage.Title>
<views:TestEnquiriesView
x:Name="TestView">
<views:TestEnquiriesView.Title>Test</views:TestEnquiriesView.Title>
</views:TestEnquiriesView>
<views:ProfileView
x:Name="ProfileView">
<views:ProfileView.Icon>
<OnPlatform x:TypeArguments="FileImageSource">
<On Platform="iOS, Android" Value="menu_profile" />
<On Platform="UWP, WinRT, WinPhone" Value="Assets\menu_profile.png" />
</OnPlatform>
</views:ProfileView.Icon>
</views:ProfileView>
解决方案
您可以尝试在 的子元素上添加 Title 属性TabbedPage
。在 UWP 中,TabbedPage
识别Title
子元素的属性并将其用作选项卡的显示文本。
此行为与 Android 不同。Android 中设置的图标无法在 UWP 中显示为显示文本。
最好的祝福。
推荐阅读
- javascript - 难以理解这个 Promise + async await 示例以在 JavaScript 中检索多个用户信息
- python - matplotlib twinx() 同一左轴上的第二个轴标记
- swift - 使用按钮获取核心数据中的索引
- javascript - 如何修复 Invariant Violation:元素类型无效:预期为字符串(对于内置组件)
- bash - 关于 Bash 脚本的问题——如何计算文件中的评论并过滤掉特定评论?
- bash - 使用自动机创建服务,咖啡因
- python - 密码验证失败 + Docker + Django
- c - rm 成功但它打印出 rm: cannot remove '': No such file or directory
- javascript - 在 for 循环中读取数组项时未定义
- reactjs - 从谷歌登录传递用户名和姓氏