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

大兔子大兔子 提交于 2019-12-24 13:33:44

问题


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


回答1:


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>




回答2:


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.



来源:https://stackoverflow.com/questions/16147423/how-to-superscript-some-text-in-a-textbox-textblock-control-in-windows-phone-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!