图标未出现在TabbedPage上

时间:2019-09-25 17:45:01

标签: visual-studio xaml xamarin

请参见下面的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>

app_settings.png和menu_profile.png在Android上正确显示,但是在UWP上仅显示menu_profile.png。为什么?

偶然地,页面上有两个警告:

1)The attachable property ToolbarItems was not found in type ContentPage在此行:<ContentPage.ToolbarItems>

2)The property default is set more than once在此行:<On Platform="UWP, WinRT, WinPhone" Value="Assets\menu_profile.png" />

我正在使用Visual Studio 2017。

1 个答案:

答案 0 :(得分:0)

尝试将/更改为\

使用代码:

<On Platform="UWP, WinRT, WinPhone" Value="Assets\app_settings.png" />

代替

<On Platform="UWP, WinRT, WinPhone" Value="Assets/app_settings.png" />