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

发布于 2024-10-12 08:18:16 字数 562 浏览 2 评论 0原文

在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?

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.BaselineAlignmentProperty in Web Application ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心舞飞扬 2024-10-19 08:18:16

Silverlight 不支持 BaseLineAlignment,但是您可以使用 Unicode 实现上标,只需将以下内容放入代码隐藏中即可实现目的。

    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;

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文