Set superscript and subscript in formatted text in

2019-01-06 17:36发布

How can i set some text as subscript/superscript in FormattedText in wpf

8条回答
smile是对你的礼貌
2楼-- · 2019-01-06 18:22

I don't know if you need this to work with FormattedText specifically, or you mean derivations of Inline, but the following will work on Inlines, even if Typography.Variants="Superscript" fails to work.

TextRange selection = new TextRange(document.ContentStart, document.ContentEnd);
selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, BaselineAlignment.Superscript);

Hope it helps!

查看更多
做自己的国王
3楼-- · 2019-01-06 18:34

This is the only thing that worked for me. It also gives you more control over the alignment and font size.

<TextBlock Grid.Row="17">
    3 x 3<Run FontSize="6pt" BaselineAlignment="TextTop">2</Run>)
</TextBlock>
查看更多
登录 后发表回答