JJS
JJS

Reputation: 1156

WP8: RichTextBox has no Document property

So I have a RichTextBox on my xaml page in my WP8 project, set up like this:

<RichTextBox x:Name="ContentDisplay" IsReadOnly="True">

</RichTextBox>

I'm trying to get it to display some text. Every single piece of code I find on the net references Document property. However, when I try to do anything with it, it just isn't there. There's no

var test = ContentDisplay.Document;

to set to.

When I try to compile the project with aforementioned line, I get a following error:

'System.Windows.Controls.RichTextBox' does not contain a definition for 'Document'
and no extension method 'Document' accepting a first argument of type 'System.Windows.Controls.RichTextBox' could be found 
(are you missing a using directive or an assembly reference?)   

Trying to google it, i find references to a similar but-not-the-same problem, this time with people trying to use 'Text' property (which, unlike Document property, doesn't even exist) So, please tell, how can I use that control?

Upvotes: 0

Views: 1442

Answers (1)

Alaa Masoud
Alaa Masoud

Reputation: 7135

You add content to this control using Blocks and Paragraphs. The following will add another line to the RichTextBlox.

var paragraph = new Paragraph();
paragraph.Inlines.Add("Hello");
richText.Blocks.Add(paragraph);
<RichTextBox x:Name="richText">
  <Paragraph>
    <Run Text="Line one" />
  </Paragraph>
</RichTextBox>

The Document property is available on the Silverlight version of the control. Unfortunately, not all features were ported to windows phone.

Upvotes: 1

Related Questions