superscripts are not coming in wpf richtext box

Viewed 913

I have implemented a custom rich text box in a wpf mvvm application and have given option to format the entered text like this:

<Button Style="{StaticResource formatTextStyle}"
        Command="EditingCommands.ToggleBold" ToolTip="Bold">
   <TextBlock FontWeight="Bold">B</TextBlock>
</Button>

I am using EditingCommands.ToggleBold to make the text bold. In the same way I am giving the option for ToggleSuperscript

<Button Style="{StaticResource formatImageStyle}" 
        Command="EditingCommands.ToggleSuperscript" ToolTip="Superscript">
   <TextBlock FontStyle="Italic" FontWeight="Bold">SubScript</TextBlock>
</Button>

but its not working...

Here StaticResource is

<Style TargetType="{x:Type Button}" x:Key="formatTextStyle">
   <Setter Property="FontFamily" Value="Palatino Linotype"></Setter>
   <Setter Property="Width" Value="30"></Setter>
   <Setter Property="FontSize" Value ="14"></Setter>
   <Setter Property="CommandTarget" Value="{Binding ElementName=mainRTB}"/>
</Style>

and mainRTB is my RichTextBox name.

<RichTextBox Name="mainRTB" AcceptsTab="True" Height="160"
             asis:RichTextboxAssistant.BoundDocument="{Binding Path=Text, 
                                             ElementName=uxRichTextEditor}"
             VerticalScrollBarVisibility="Visible" />

I am clueless on this. Can any body suggest how to enable ToggleSuperscript and ToggleSubscript.

3 Answers

use Typography.variants:

<Paragraph FontFamily="Palatino Linotype">
  2<Run Typography.Variants="Superscript">3</Run>
  14<Run Typography.Variants="Superscript">th</Run>
</Paragraph>
Related