views:

150

answers:

2

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?

A: 

Try pr.Margin = new Thickness(0.0) to remove the gaps between paragraphs.

Julien Lebosquain
A: 

According to the documentation, Paragraph spacing is defined by margins, which do not accumulate (no doubling up), so Julien Lebosquain's answer is correct.

MSDN on FlowDocument Paragraph Spacing

IanGilham