Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在处理过程中,没有文本写入RichTextBox_C#_Wpf_Richtextbox_Dispatcher - Fatal编程技术网

C# 在处理过程中,没有文本写入RichTextBox

C# 在处理过程中,没有文本写入RichTextBox,c#,wpf,richtextbox,dispatcher,C#,Wpf,Richtextbox,Dispatcher,我有一个RichTextBox,我只想在那里写一些信息 FlowDocument _content = new FlowDocument(); this.Dispatcher.Invoke(() => { _content.Blocks.Add(new Paragraph(new Run("START READING FROM FILE..."))); }); //Code that reads data from an Excel file... this.Dispatc

我有一个RichTextBox,我只想在那里写一些信息

FlowDocument _content = new FlowDocument();

this.Dispatcher.Invoke(() =>
{
     _content.Blocks.Add(new Paragraph(new Run("START READING FROM FILE...")));
});

//Code that reads data from an Excel file...

this.Dispatcher.Invoke(() =>
{
     _content.Blocks.Add(new Paragraph(new Run("END READING FROM FILE...")));
});
但是开始文本永远不会写入RichTextBox。它正在读取Excel文件,但没有将这些文本写入RichTextBox


我尝试了在网站上找到的几种方法,但在过程中无法将文本输入到RichTextBox。

将RichTextBox的文档属性设置为“内容”。那么您的示例就可以运行了。

您是否将theRichTextBox的文档属性设置为“内容”?那么你的例子就行了。@mm8是的,我确实忘了将文档设置为_content,它现在就行了。非常感谢。