我正在尝试在一个新的毛伊岛项目中使用FontAwesome5。当我从字面上引用xaml中的字形时,图标就会呈现得很好。但是,当我试图让静态类资源支持它时,不会呈现字形,而是呈现一个字符串。
因此,这将正确地呈现图标:
<Image Grid.Column="1" WidthRequest="40" HeightRequest="40" Margin="5,5,10,5" VerticalOptions="Center">
<Image.Source>
<FontImageSource FontFamily="{x:Static font:FontAwesome.Duotone}" Glyph="" />
</Image.Source>
</Image>但是,当将它移到引用时,它不会:
<Image Grid.Column="1" WidthRequest="40" HeightRequest="40" Margin="5,5,10,5" VerticalOptions="Center">
<Image.Source>
<FontImageSource FontFamily="{x:Static font:FontAwesome.Duotone}" Glyph="{x:Static font:FontAwesome.Share}" />
</Image.Source>
</Image>其中FontAwesome.Share位于静态类中,包含:
[XamlCompilation(XamlCompilationOptions.Compile)]
public static class FontAwesome
{
// ...
public static string Share = "";
// ...
}有什么想法吗?
发布于 2022-11-26 01:14:42
井。我不知道为什么,但以下几点起作用:
public static string Share = '\uf064'.ToString();希望那会有帮助,未来的人!
https://stackoverflow.com/questions/74577923
复制相似问题