5

I have a Label with Font set to an icons font (font awesome) which has the Text bound like this:

<Label Text='{Binding Icon}'>
  <Label.FontFamily>
    <OnPlatform x:TypeArguments="x:String">
        <OnPlatform.iOS></OnPlatform.iOS>
        <OnPlatform.Android>icons.ttf#Icons</OnPlatform.Android>
    </OnPlatform>
 </Label.FontFamily>
</Label>

it doesn't render the icon, it renders the Unicode value &#xf032; instead.

It works if I set the text without binding, like this:

<Label Text='&#xf032;'>

I suspect there's some kind of race condition between setting the text and the font.

I need the binding, but I don't know any workarounds.

Don Box
  • 3,166
  • 3
  • 26
  • 55

2 Answers2

9

Return the escape sequence of \uf032 from your binding instead of instead of &#xf032;

SushiHangover
  • 73,120
  • 10
  • 106
  • 165
0

SushiHangover's works in my case but if you're using Font Awesome Material Design Icons (referenced in my XAML as materialdesignicons.ttf#Material Design Icons) or any Unicode character that exceeds 0xFFFF, you need to use a syntax like this:

"\U000F09D7"
MAXE
  • 4,978
  • 2
  • 45
  • 61