littlegreendude
littlegreendude

Reputation: 117

How do you add superscript to a label in Xamarin Forms using Xaml

How do you add superscript to a label in Xamarin Forms using Xaml. Specifically, I would like to add a TM superscript for trademark.

Upvotes: 3

Views: 2307

Answers (2)

Jeff W.
Jeff W.

Reputation: 61

Set the Label's TextType property to Html.

For example, to produce: x2 + y

In XAML:

<Label Text="x&lt;sup&gt;&lt;small&gt;2&lt;/small&gt;&lt;/sup&gt; + y" TextType="Html"/>

or

<Label TextType="Html">
    <![CDATA[
    x<sup><small>2</small></sup> + y
    ]]>
</Label>

In C#:

Label myLabel=new Label{TextType=TextType.Html,Text="x<sup><small>2</small></sup> + y"}

Note that the <small> tag is optional.

For more information, see the "Display HTML" section of the Label documentation: Xamarin.Forms Label: Display HTML

Upvotes: 2

Prashant Cholachagudda
Prashant Cholachagudda

Reputation: 13090

As Chris mentioned in the comment you can use the unicode character &#8482; (™)

You should use the CustomeRenderer if you want to do anything complex

Upvotes: 5

Related Questions