开发者

Underlining RichTextArea content by default in Silverlight 4

I'm uisng a RichTextArea to display my html content in SL 4,I want to underline the content displayed by the control ( without modifying the htm开发者_运维技巧l) and also attach an event of Onclick on the text . I tried different options i.e using RichTextArea in the content template of a Hyperlinkbutton but as the content of RichTextArea cannot be set directly, this was ruled out. Any suggestions ?


All you need to do is to surround your content with an 'Underline' element.

Here is how you can do it in XAML:

<RichTextBox>
    <Paragraph>
        <Underline>
                Underlined Content
        </Underline>
    </Paragraph>
</RichTextBox>

Here is how you can do it in C#:

RichTextBox richTextBox = new RichTextBox();
Paragraph paragraph = new Paragraph();
Underline underline = new Underline();
Run run = new Run() { Text = "Underlined Content" };

underline.Inlines.Add(run);
paragraph.Inlines.Add(underline);
richTextBox.Blocks.Add(paragraph);

Good luck,
Jim McCurdy
Face to Face Software and YinYangMoney

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜