Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Superscript and Subscript in WP7

I'm trying to show "H2O" with the 2 in subscript in a PivotItem Header.

E.g.

<controls:PivotItem Header="H20">
</controls:PivotItem>

I'd also like to assign the same value from code behind to TextBlock.Text.

E.g.

textBlock1.Text = "H2O"; // 2 to appear as subscript.

Is this possible with the version of Silverlight used for WP7?

like image 835
Daniel Ballinger Avatar asked Mar 28 '26 01:03

Daniel Ballinger


1 Answers

After some searching around I found a solution.

From SubScript and SuperScript in TextBlock by Troels Pedersen and lordcheeto respectively.

In the XAML the subscript 2 can be expressed via Unicode.

E.g.

<controls:PivotItem Header="H&#x2082;0">
</controls:PivotItem>

And similarly for the code behind.

E.g.

textBlock1.Text = "H\x2082O"; // 2 appears as subscript.

There are some limitations on this approach as only characters in the Basic Multilingual Plane (0000-FFFF) are supported and the font being used also needs to support the characters.

like image 77
Daniel Ballinger Avatar answered Mar 30 '26 11:03

Daniel Ballinger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!