1
votes

I have:

<ContentPage.ToolbarItems>
    <ToolbarItem Text="{Binding [AddPhoto]}" Command="{Binding AddNewPhotoCommand}" Order="Primary" x:TypeArguments="FileImageSource" Icon="{OnPlatform iOS='photo.png', UWP='Assets/photo.png'}"/>
</ContentPage.ToolbarItems>

and I got:

Type ToolbarItem not found in xmlns http://xamarin.com/schemas/2014/forms

If I remove entire part after x:TypeArguments="FileImageSource" mean

 <ToolbarItem Text="{Binding [AddPhoto]}" Command="{Binding AddNewPhotoCommand}" Order="Primary"/>

then is fine, no error.

I upgraded project to Xamarin 3.3.0 and I changed from

<ToolbarItem Text="{Binding [AddPhoto]}" Command="{Binding AddNewPhotoCommand}" Order="Primary" >
      <ToolbarItem.Icon>
        <OnPlatform x:TypeArguments="FileImageSource">
          <On Platform="iOS" Value="photo.png"/>
          <On Platform="UWP" Value="Assets/photo.png"/>
        </OnPlatform>
      </ToolbarItem.Icon>
</ToolbarItem>

to

<ToolbarItem Text="{Binding [AddPhoto]}" Command="{Binding AddNewPhotoCommand}" Order="Primary" x:TypeArguments="FileImageSource" Icon="{OnPlatform iOS='photo.png', UWP='Assets/photo.png'}"/>

Why ?

I don't have typo or something like that.

1

1 Answers

0
votes

Check out how it should be used:

<ContentPage Title="Browse">
        <ContentPage.Icon>
            <OnPlatform x:TypeArguments="FileImageSource">
                <On Platform="iOS">tab_feed.png</On>
                <On Platform="Android>tab_feedand.png</On>
                <On Platform="UWP>/Images/tab_feed.png</On>
            </OnPlatform>
        </ContentPage.Icon>
    </ContentPage>

Will become:

<ContentPage Title="Browse" Icon="{x:OnPlatform iOS='tab_afeed.png', Android='tab_feedand.png', UWP='/Images/tab_feed.png' />

No need to specify x:TypeArguments.

x:typeArguments passes constraining type arguments of a generic to the constructor of the generic type. So it's related to OnPlatform method, but you specify it for ToolbarItem.