Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.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
如何在WPF C#中设置richtextbox中文本的行距?_C#_Wpf_Richtextbox_Flowdocument - Fatal编程技术网

如何在WPF C#中设置richtextbox中文本的行距?

如何在WPF C#中设置richtextbox中文本的行距?,c#,wpf,richtextbox,flowdocument,C#,Wpf,Richtextbox,Flowdocument,当我使用richtextbox进行文本编辑时,会有很大的行距,但是当我在FlowDocument中打开相同的文本/文件时,它看起来非常好。是否有一种简单的方法来更改richtextbox中的行距,以便与FlowDocument的行距相匹配 Paragraph paragraph = new Paragraph(); paragraph.Inlines.Add(dataContent); FlowDocument document = new FlowDocument(paragraph); s

当我使用richtextbox进行文本编辑时,会有很大的行距,但是当我在FlowDocument中打开相同的文本/文件时,它看起来非常好。是否有一种简单的方法来更改richtextbox中的行距,以便与FlowDocument的行距相匹配

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

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

第1段
第2段

试一试。

这解决了我的问题,但我动态添加了richtextbox,那么如何在代码中而不是在XAML中解决问题呢?
段落p=new段落();p、 线宽=50;流程文件fd=新流程文件(p);rtbShow.Document=fd
   <RichTextBox >
        <FlowDocument>
            <Paragraph LineHeight="50">
                Paragraph1
            </Paragraph>
            <Paragraph LineHeight="20">
                Paragraph2
            </Paragraph>
        </FlowDocument >
    </RichTextBox>