none
Superscript in WPF RichTextBox RRS feed

  • Question

  • Why doesn't this work?

    EditingCommands.ToggleSuperscript.Execute(null, rtb);

    Where rtb is a RichTextBox.

    Tuesday, September 9, 2008 9:34 PM

Answers

  • This code works pretty well for me:

    <RichTextBox x:Name="rtb">
      <FlowDocument FontFamily="Palatino Linotype" FontSize="30"/>
    </RichTextBox>

    rtb.PreviewKeyDown += (sender, e) =>
    {
        if (e.Key == Key.F2)
        {
            EditingCommands.ToggleSuperscript.Execute(null, rtb);
        }
    };

    It seems that the superscript and subscript is "only" enabled for open type font, try using an open type font like "Palatino Linotype" instead.

    Hope this helps
    • Marked as answer by Marco Zhou Tuesday, September 16, 2008 9:45 AM
    Friday, September 12, 2008 7:38 AM

All replies

  • This code works pretty well for me:

    <RichTextBox x:Name="rtb">
      <FlowDocument FontFamily="Palatino Linotype" FontSize="30"/>
    </RichTextBox>

    rtb.PreviewKeyDown += (sender, e) =>
    {
        if (e.Key == Key.F2)
        {
            EditingCommands.ToggleSuperscript.Execute(null, rtb);
        }
    };

    It seems that the superscript and subscript is "only" enabled for open type font, try using an open type font like "Palatino Linotype" instead.

    Hope this helps
    • Marked as answer by Marco Zhou Tuesday, September 16, 2008 9:45 AM
    Friday, September 12, 2008 7:38 AM
  • why should it work only on certan fonts?
    Thursday, October 7, 2010 6:30 AM