在运行时在WPF RichTextBox中的新行中添加文本 [英] Adding text in a new line in WPF RichTextBox at runtime
本文介绍了在运行时在WPF RichTextBox中的新行中添加文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在运行时在WPF RichTextBox中添加一些新行. 我可以使用:
I want to add some text in a WPF RichTextBox at runtime in a new line. I can do this using:
FlowDocument mcFlowDoc = new FlowDocument();
mcFlowDoc = richTextBox.Document;
Paragraph pr = new Paragraph();
pr.Inlines.Add(status);
mcFlowDoc.Blocks.Add(pr);
StatusText.Document = mcFlowDoc;
但是两行之间的差距太大.我该如何解决?
But there is too much of a gap between two lines. How can I fix this?
推荐答案
根据文档,段落间距是由边距定义的,这些边距不会累积(不加倍),因此Julien Lebosquain的答案是正确的.
According to the documentation, Paragraph spacing is defined by margins, which do not accumulate (no doubling up), so Julien Lebosquain's answer is correct.
这篇关于在运行时在WPF RichTextBox中的新行中添加文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文