我的面向 Xamarin 的 UWP 应用缺少选项卡 [英] Tabs are missing from my UWP app that targets Xamarin

查看:24
本文介绍了我的面向 Xamarin 的 UWP 应用缺少选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个简单的 Xamarin 应用程序,它包含两个页面,每个页面都通过 Tab 键访问,如下所示:

I have created a simple Xamarin application, which contains two pages and each page is accessed by tabbing as shown below:

Android 目标工作正常(如上面的屏幕截图所示),所以我现在添加了一个 UWP 目标.问题是 UWP 目标只显示一个页面,即没有选项卡,因此无法在两个页面之间使用选项卡.

The Android target is working correctly (shown in the screenshot above) so I have now added a UWP target. The problem is that the UWP target only displays one page i.e. there is no tab, so no way to tab between the two pages.

如何将选项卡添加到 UWP 应用?请注意,我在创建 UWP 应用时使用了选项卡模板.

How can I add the tabs to the UWP app? Note that I used a tab template when I created the UWP app.

其他一切都按预期工作(标签除外).

Everything else works as expected (except the tabs).

我使用的是 Visual Studio 2017.

I am using Visual Studio 2017.

这是主页的 XAML:

Here is the XAML of the main page:

<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>

推荐答案

您可以尝试在 TabbedPage 的子元素上添加 Title 属性.在 UWP 中,TabbedPage 识别子元素的 Title 属性并将其用作选项卡的显示文本.

You can try adding a Title property on a child element of TabbedPage. In UWP, TabbedPage recognizes the Title property of the child element and uses it as the display text of the tab.

此行为与 Android 不同.Android 中设置的图标无法在 UWP 中显示为显示文本.

This behavior is different from Android. Icons set in Android cannot appear as display text in UWP.

这是TabbedPage 文档.

最好的问候.

这篇关于我的面向 Xamarin 的 UWP 应用缺少选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆