w0051977
w0051977

Reputation: 15817

Tabs are missing from my UWP app that targets Xamarin

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

enter image description here

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.

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

I am using Visual Studio 2017.

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>

Upvotes: 2

Views: 236

Answers (1)

Anran Zhang
Anran Zhang

Reputation: 7727

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.

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

Here is the TabbedPage document.

Best regards.

Upvotes: 1

Related Questions