2013-07-10 25 views
0

所以,我有我的XAML頁面上的一個RichTextBox我WP8項目,設立這樣的:WP8:RichTextBox中沒有文檔屬性

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

</RichTextBox> 

我試圖得到它顯示一些文本。我在網上找到的每一段代碼都引用了文檔屬性。但是,當我試圖用它做任何事情時,它就不在那裏。沒有

var test = ContentDisplay.Document; 

設置爲。

當我嘗試編譯與前述線項目,我得到了以下錯誤:

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

試圖谷歌,我找到一個類似的但並非最相同的問題的參考,這時候人們試圖使用「文本」屬性(與文檔屬性不同,它甚至不存在) 因此,請告訴我如何使用該控件?

回答

1

您可以使用BlocksParagraphs將內容添加到此控件中。以下內容將在RichTextBlox中添加另一行。

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

文檔屬性可在控制的Silverlight的版本。不幸的是,並不是所有的功能都被移植到windows phone上。