Search code examples
c#wpfrichtextboxflowdocument

How to set the line spacing for text in richtextbox in WPF C#?


When I use richtextbox for text editing, there is a huge line spacing, but when I open the same text/file in FlowDocument it looks perfectly fine. Is there a simple way to change the line spacing in richtextbox as well to match with that of the FlowDocument?

Paragraph paragraph = new Paragraph();
paragraph.Inlines.Add(dataContent);

FlowDocument document = new FlowDocument(paragraph);
selectedRTB.Document = document;
selectedTabItem.Content = selectedRTB;

Solution

  •    <RichTextBox >
            <FlowDocument>
                <Paragraph LineHeight="50">
                    Paragraph1
                </Paragraph>
                <Paragraph LineHeight="20">
                    Paragraph2
                </Paragraph>
            </FlowDocument >
        </RichTextBox>
    

    have a try.