How do I change RichTextBox paragraph spacing?
I am using a RichTextBox in WPF, and am trying to set the default paragraph spacing to 0 (so that there is no paragraph spacing). While I could do this in XAML, I would like to achieve it programmatically if possible. Any ideas?
I did it with style (pun indented)
<RichTextBox Margin="0,51,0,0" Name="mainTextBox" >
<RichTextBox.Resources>
<Style TargetType="{x:Type Paragraph}">
<Setter Property="Margin" Value="0"/>
</Style>
</RichTextBox.Resources>
</RichTextBox>
Using Line Height
RichTextBox rtb = new RichTextBox();
Paragraph p = rtb.Document.Blocks.FirstBlock as Paragraph;
p.LineHeight = 10;
Close, so you got the points. Actually it turned out to be setting the margin,
p.Margin = new Thickness(0);
For me on VS2017 in WPF works this:
<RichTextBox HorizontalAlignment="Left" Height="126" Margin="10,280,0,0" VerticalAlignment="Top" Width="343" FontSize="14" Block.LineHeight="2"/>
The key is Block.LineHeight="2"
You can found this also in Properties view but you can't change below 6px from there.