How to Superscript some Text in a TextBox/TextBloc

2019-07-31 22:32发布

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

2条回答
闹够了就滚
2楼-- · 2019-07-31 23:15

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.

查看更多
看我几分像从前
3楼-- · 2019-07-31 23:25

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

查看更多
登录 后发表回答