【发布时间】:2011-03-14 06:36:52
【问题描述】:
<RichTextBox AcceptsTab="True" ForceCursor="True" IsDocumentEnabled="True" TextChanged="ContentChanged" Name="TextContent"/>
在 C# 文件中,我无法获取富文本框的 Text 属性。 我正在努力做到这一点;
TextContent.Text= "hello"
但它给出了编译时错误。
'System.Windows.Controls.RichTextBox' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'System.Windows.Controls.RichTextBox' could be found (are you missing a using directive or an assembly reference?)
请给我建议。
【问题讨论】:
-
你需要用到 Document 属性,看这里:stackoverflow.com/questions/957441/…
-
您真的在尝试读取或写入内容吗?因为您在示例中询问如何获取并尝试设置...无论如何,我在下面的答案中添加了示例。
标签: c# wpf richtextbox