因此,我在WP8项目中的xaml页面上有一个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?) 尝试用谷歌搜索,我发现了一个类似但不相同的问题,这一次是人们试图使用“Text”属性(与文档属性不同,它甚至不存在),所以,请告诉我,我如何使用那个控件?
发布于 2013-07-10 16:23:38
您可以使用Blocks和Paragraphs向此控件添加内容。下面的代码将向RichTextBlox中添加另一行。
var paragraph = new Paragraph();
paragraph.Inlines.Add("Hello");
richText.Blocks.Add(paragraph);<RichTextBox x:Name="richText">
<Paragraph>
<Run Text="Line one" />
</Paragraph>
</RichTextBox>Document属性在Silverlight版本的控件上可用。不幸的是,并不是所有的功能都能移植到windows phone上。
https://stackoverflow.com/questions/17564772
复制相似问题