The less than sign (<), greater than sign (>), ampersand (&), apostrophe (') and double quote (") have special meaning within an XML file. Therefore, if you want to use these reserved characterss within a Text property or Content property, you need to use the XML escape characters.
The short answer is to use & to encode an ampersand.
To open the XAML Designer, right-click a XAML file in Solution Explorer and choose View Designer. to switch which window appears on top: either the artboard or the XAML editor.
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"></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.
From Microsoft documentation:
Markup files that are created in Microsoft Visual Studio are automatically saved in the Unicode UTF-8 file format, which means that most special characters, such as accent marks, are encoded correctly. However, there is a set of commonly-used special characters that are handled differently. These special characters follow the World Wide Web Consortium (W3C) XML standard for encoding.
What this means is that you can do zalgo for all you care
Bit of code that is relevant:
<Label Grid.Column="0" Grid.Row="3" FontWeight="ExtraBlack">STAGE:Mͣͭͣ̾ Vͣͥͭ͛ͤͮͥͨͥͧ̾</Label>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With