Xamarin Forms,导入图标时 App.xaml 内部出现 "Invalid syntax for a hexadecimal numeric entity reference" 错误

Xamarin Forms, "Invalid syntax for a hexadecimal numeric entity reference" error inside App.xaml when importing Icon

font.otf 已正确导入并放置在正确的文件夹中,因为字体适用于字母,但由于语法错误,无法从 otf 文件导入图标。在图标代码“uf1ea”之前输入 &#x 是导致错误的原因,但找到图标很重要,否则它只会在模拟器上显示“uf1ea”,而不是实际图标。

这是我在 app.xaml 中编写的代码片段:

    <?xml version="1.0" encoding="utf-8" ?>
<Application xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="testingfont.App">
    <Application.Resources>
        <ResourceDictionary>
            <x:String x:Key="Newspaper">&#xuf1ea;</x:String>
        </ResourceDictionary>
    </Application.Resources>
</Application>

您无需在图标代码中添加 u,只需按如下方式使用即可:

<x:String x:Key="Newspaper">&#xf1ea;</x:String>

在新 class 中添加图标代码后,这对我有用:

<Label Text="&#xf1ea;"/>