首页 > 解决方案 > 如何在 Xamarin Forms 中从 Font-Awesome 中排除字符串

问题描述

如何将字符串从格式化中排除为 Font-Awesome 图标?

在我的例子中,我在 XAML 中有一个标签,它有一个文本绑定到一个字符串。这个标签的字体系列是 Font-Awesome。在我的 C# 代码中,字符串如下所示:

CurrentSorting = "Date \xf062";

输出如下所示:

D@e(和 \xf062 图标)

但是我希望输出是这样的:

日期(和 \xf062 图标)

我怎样才能做到这一点?

[编辑]

我在 XAML 中的标签:

<Label 
     Margin="10,0,0,0"
     TextColor="#FF9340"
     Text="{Binding CurrentSorting}"
     FontFamily="{StaticResource Font-Awesome}"
     HeightRequest="40"
     VerticalTextAlignment="Center"/>

C#代码:

case "4":
                {
                    CurrentSorting = "Date \xf062";
                    Entries = new ObservableCollection<Entry>(Entries.OrderBy(x => x.Date).ToList());
                    break;
                }

资源字典:

<OnPlatform x:TypeArguments="x:String" x:Key="Font-Awesome">
            <On Platform="Android" Value="Font-Awesome.ttf#Font-Awesome" />
            <!--<On Platform="iOS" Value="Raleway-SemiBold" />-->
</OnPlatform>

在我的手机上输出: 在此处输入图像描述

标签: c#xamarin.formsiconsfont-awesome

解决方案


推荐阅读