Silverlight 4的上标在RichTextBox中的Web应用程序应用程序、上标、Silverlight、Web

2023-09-06 22:52:15 作者:激萌少女

在WPF标是:

        var currentAlignment = richTextBox.Selection.GetPropertyValue(Inline.BaselineAlignmentProperty);
        BaselineAlignment newAlignment = ((BaselineAlignment)currentAlignment == BaselineAlignment.Superscript) ? BaselineAlignment.Baseline : BaselineAlignment.Superscript;
        richTextBox.Selection.ApplyPropertyValue(Inline.BaselineAlignmentProperty, newAlignment);
        richTextBox.Selection.ApplyPropertyValue(Inline.FontSizeProperty, (double)8); 

但如何在Web应用程序实现Inline.BaselineAlignmentProperty?

But how to implement Inline.BaselineAlignmentProperty in Web Application ?

推荐答案

Silverlight不支持BaseLineAlignment,但你可以通过使用统一code ++实现标,只是把你的$ C $下面的C-落后,因此,将这样的伎俩。

Silverlight does not support BaseLineAlignment, however you could achieve superscript by using Unicode, just put the following in your code-behind and it will do the trick.

    string superscript = string.Empty;
    switch (SerialNo)
    {
        case 1:
            superscript = "\x00B9";
            break;
        case 2:
            superscript = "\x00B2";
            break;
        case 3:
            superscript = "\x00B3";
            break;
        case 4:
            superscript = "\x2074";
            break;
        case 5:
            superscript = "\x2075";
            break;
        case 6:
            superscript = "\x2076";
            break;
        case 7:
            superscript = "\x2077";
            break;
        case 8:
            superscript = "\x2078";
            break;
        case 9:
            superscript = "\x2079";
            break;
        default:
            superscript = "\x2070";
            break;
    }
    label.Content += superscript;