XAML XLS0504属性'FontFamily'不支持'OnPlatform '1(T)' Xamarin窗体类型的值

bvn4nwqk  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(104)

我正在尝试将fontawsome图标添加到我的Xamarin forms项目中。我正在执行this tutorial to do so。但是,当我使用以下代码时,

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

它显示了一个误差,即XLS0504 Property 'FontFamily' does not support values of type 'OnPlatform 1(T)'。
如何解决此错误?

Xamarin Version - 5.0.0.2012
bz4sfanl

bz4sfanl1#

这是因为您需要将FontFamily指定为String
请尝试以下操作:

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

祝你好运!

相关问题