How to insert special characters content in XAML?

Suppose you want to have a button with that displays < Click Here >. Doing this the traditional way

<Button x:Name="btn"><Click Here></Button> 

will drive you to troubles becuase the XAML parser will think that you want to create an element called Click with an attribute called here. Therefore, you need to encode the special characters in your code.

Less than (<) &lt;

Greater than (>) &gt;

Quotation mark (“) &quot;

Ampersand (&) &amp;

Therefore, you will instead need to write your statement as follows:

<Button x:Name=”btn”> &lt;Click Here&gt; </Button>

Special Character Character Entity
Less than (<) &lt;
Greater than (>) &gt;
Ampersand (&) &amp;
Quotation mark (“) &quot

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: