Amit Singh
Amit Singh

Reputation: 2698

How to Superscript some Text in a TextBox/TextBlock Control in windows phone 8?

I'm working on windows phone 8 app, and m stuck here, guys i want to show some text as a superscript either in TextBox or in TextBlock where-ever possible. suggest me how can i obtained it. Thanks

Upvotes: 1

Views: 1283

Answers (2)

w0rd-driven
w0rd-driven

Reputation: 933

There's an alternative but it's only available in WP8: Typography.Variants.

I personally prefer this approach as it aligns more with WPF but there are cases where you have to do baseline manipulation or in this instance, margin wrangling. If WPF is any indication, it also requires a font that supports variants which are generally open type/true type only. See Superscript / subscript in hyperlink in WPF for a better explanation.

Upvotes: 0

Joe Healy
Joe Healy

Reputation: 5817

Why don't you use a stackpanel wrapping a couple of textblocks instead? Then adjust the margines on the stuff you want super and subscripted.

        <StackPanel Orientation="Vertical">
        <TextBlock Text="H2O3" FontSize="40" Margin="0,10"/>
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="H" FontSize="40" />
            <TextBlock Text="2" FontSize="40" Margin="0,-20,0,0"/>
            <TextBlock Text="O" FontSize="40"/>
            <TextBlock Text="3" FontSize="40" Margin="0,10,0,-10"/>
        </StackPanel>
    </StackPanel>

enter image description here

Upvotes: 3

Related Questions