Set superscript and subscript in formatted text in wpf

后端 未结 8 678
时光说笑
时光说笑 2020-11-27 06:37

How can I set some text as subscript/superscript in FormattedText in WPF?

8条回答
  •  时光取名叫无心
    2020-11-27 07:12

    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!

提交回复
热议问题