【发布时间】:2018-12-31 19:42:43
【问题描述】:
我想在我的 Xamarin.Forms 项目中添加很棒的字体,并且我已将它添加到项目中。 然后我将 FontFamily 添加到这样的标签中:
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="15">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="9*" />
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Text="" FontSize="20">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String">
<On Platform="iOS" Value="Font Awesome 5 Free" />
<On Platform="Android" Value="fa-regular-400.ttf#Font Awesome 5 Free Regular" />
</OnPlatform>
</Label.FontFamily>
</Label>
<Label Grid.Column="1" Text="{Binding Title}" FontSize="20"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
但是当我将这些硬编码的东西更改为这样的可绑定属性时:
<Label Grid.Column="0" Text="{Binding FontAwesomeIconText}" FontSize="20">
在c#中这样设置
menuItems = new List<DrawerMenuItem>
{
new DrawerMenuItem {Id = MenuItemType.Browse, Title="Browse", FontAwesomeIconText = "" },
new DrawerMenuItem {Id = MenuItemType.About, Title="About" , FontAwesomeIconText = ""}
};
它坏了。我看到了它的代码
我还尝试在我的 App.xaml 文件中使用 ResourcesDictionary
<OnPlatform x:TypeArguments="x:String" x:Key="FontAwesome">
<On Platform="iOS" Value="Font Awesome 5 Free" />
<On Platform="Android" Value="fa-regular-400.ttf#Font Awesome 5 Free Regular" />
</OnPlatform>
得到了同样的结果。 可能是什么问题?
【问题讨论】:
标签: c# font-awesome-5 xamarin.forms.listview