How to put a unicode character in XAML? How to put a unicode character in XAML? wpf wpf

How to put a unicode character in XAML?


Since XAML is an XML file format you could try the XML character escape. So instead of writing &\u2014, you could write — instead.


In xaml I did it like this:

    <Button Grid.Column="1" Grid.RowSpan="2" Name="start" Margin="5" Click="start_Click">        <TextBlock Name="test" FontFamily="pack://application:,,,/Y_Yoga;Component/Resources/#FontAwesome">&#xF04B;</TextBlock>    </Button>

Hope to be helpful!


I came to this page for some other reason, but this does not include the easiest and the obvious solution.

This is what I do.

Maintain a static class with all the Unicode values.

 public static class Icons{    public const string IconName = "\u2014";}

And then just bind it wherever you need it.

<TextBlock Text="{x:Static resources:Icons.IconName}" FontFamily="..."/>

This also helps you out with maintenance, all icons would be in one place to manage.