wpf 在 RichTextBox 中设置文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12726460/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setting text in a RichTextBox
提问by IMX
Possible Duplicate:
RichTextBox (WPF) does not have string property “Text”
This is ridiculous, my RichTextBox has no document or paragraph property. How am I supposed to add text to it via C#?
这太荒谬了,我的 RichTextBox 没有文档或段落属性。我应该如何通过 C# 向它添加文本?
<ScrollViewer Margin="16,56,16,16">
<RichTextBox x:Name="PREVIEWTEMP"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Top"
Padding="0,6,0,0"
Height="528"
Width="400"
IsReadOnly="True">
<Paragraph>
<Run Text="RichTextBox" />
</Paragraph>
</RichTextBox>
</ScrollViewer>
Does anyone know how to do this?
有谁知道如何做到这一点?
回答by Jay
Paragraph needs to sit inside a element.
段落需要位于元素内。
Take a look at this site, it has some good examples http://www.c-sharpcorner.com/UploadFile/mahesh/wpf-richtextbox/
看看这个站点,它有一些很好的例子http://www.c-sharpcorner.com/UploadFile/mahesh/wpf-richtextbox/

