开发者

Silverlight 4 superscript in RichTextBox in Web Application

开发者 https://www.devze.com 2023-02-05 08:15 出处:网络
in WPF superscript is: var currentAlignment = richTextBox.Selection.GetPropertyValue(Inline.BaselineAlignmentProperty);

in WPF superscript is:

        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); 

But how to implement Inline.B开发者_开发问答aselineAlignmentProperty in Web Application ?


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;
0

精彩评论

暂无评论...
验证码 换一张
取 消