母版页 Xamarin 表单上的绑定字体图标

don*_*don 2 c# binding xamarin font-awesome xamarin.forms

我正在尝试使用 Font Awesome 在我的母版页中添加字体。这是我的代码

new NavMenuItem { Id = 3, Title = "Home", TargetType = typeof(NavDetail), icon = ""}
Run Code Online (Sandbox Code Playgroud)

这是我的母版页标签代码enter code here

<Label VerticalOptions="FillAndExpand"          
    VerticalTextAlignment="Center"
    Text="{Binding icon}"                                   
    Style="{DynamicResource FontLabel}"
    FontSize="24" />
Run Code Online (Sandbox Code Playgroud)

问题是它只是按原样打印出十六进制值,而不是打印图标。如果我简单地写 Text="" 它可以工作,但是当我尝试绑定它时它不起作用。

gan*_*o55 8

正如您在Binding font awesome character in XAML to Text 中所见,您可以使用 unicode 格式实现它。

您可以使用浏览器获取 unicode 值:

在此处输入图片说明

你只需要在斜杠('/')后添加一个u


Ven*_*ana 6

试试下面的

icon = ((char)0xf015).ToString();
Run Code Online (Sandbox Code Playgroud)