views:

43

answers:

1

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 html) 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 ?

+1  A: 

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

Jim McCurdy
Rahul, did this answer your question? If so, could you mark it as answered?
Jim McCurdy