Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Label with custom font and text with binding doesn't work

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.

like image 592
Don Box Avatar asked Aug 04 '17 11:08

Don Box


1 Answers

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

like image 170
SushiHangover Avatar answered Nov 20 '22 23:11

SushiHangover