Home > database >  XLS0504 Property 'FontFamily' does not support values of type 'OnPlatform`1 (T)'
XLS0504 Property 'FontFamily' does not support values of type 'OnPlatform`1 (T)'

Time:09-29

I'm trying to add fontawsome icons to my Xamarin forms project. I am following this tutorial to do so. However, when I use the following code,

<Button.FontFamily>
             <OnPlatform></OnPlatform>
</Button.FontFamily>

It shows an error. which is, XLS0504 Property 'FontFamily' does not support values of type 'OnPlatform1 (T)'`.

How can I resolve this error?

Xamarin Version - 5.0.0.2012

CodePudding user response:

Well that's because you need to specify FontFamily as a String

Try something like the below:

<Button.FontFamily> 
   <OnPlatform x:TypeArguments="x:String"> 
   <On Platform="iOS" Value="iOSFont" /> 
   <On Platform="Android" Value="AndroidFont" /> 
   <On Platform="UWP" Value="UWPFont" /> 
   </OnPlatform> 
</Button.FontFamily>

Good luck!

  • Related