C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » Xamarin

How to use special symbols in label as text using Xamarin?

In this article, we are going to learn how to use/print special symbols in label as text in Xamarin?
Submitted by Ridhima Agarwal, on December 07, 2017

As we know that how to write text in Xamarin? We write it using <Label> tag. In this, if we try to write some special symbols like '&' (ampersand), '<' (less than), etc. Then the error will be thrown like these symbols are invalid.

So to avoid these errors, in order to use special symbol, we can write their HTML codes in label under text property.

This is the code showing some special symbols printed on the screen,

<StackLayout Padding="30">
	<Label Text="This is Ampersand symbol" TextColor="Black" FontSize="Large"></Label>
	<Label Text="&amp;" FontSize="Medium" TextColor="Red"></Label>
	<Label Text="This is less than symbol" TextColor="Black" FontSize="Large"></Label>
	<Label Text="&lt;" FontSize="Medium" TextColor="Red"></Label>
	<Label Text="This is greater than symbol" TextColor="Black" FontSize="Large"></Label>
	<Label Text="&gt;" FontSize="Medium" TextColor="Red"></Label>
	<Label Text="This is double quotes symbol" TextColor="Black" FontSize="Large"></Label>
	<Label Text="&quot;" FontSize="Medium" TextColor="Red"></Label>

The format used here is that the symbol we want to print, we will write the abbreviated form for that symbol following the ‘&’ sign and followed by semicolon ';'.


  • For printing Ampersand sign <Label Text="&amp;"/> is used.
  • For less than sign <Label Text="&lt;">
  • For greater than sign <Label Text="&gt;"/>
  • For double quotes <Label Text="&quot;"/>

Also for adding some additional features the font size for the labels is set using the FontSize="Medium" attribute.

TextColor="Red" attribute is used to set the color of the text.

<StackLayout> tag is used so that the view content can come in order without overlapping on each other.

Padding="30" property is used so as to give equal spacing from all the four sides, here spacing of 30 is used.

This is the screenshot of the above code:

how to print/use special symbols in xamarin under label