There is a RichTextBox with Paragraph inside it. How to change margin of the inner paragraph? There is no such property. Setting of RichTextBox.Padding to "-12,0" helps, but looks like an ugly hack.
By default RichTextBox will have a margin (12,0,12,0) for its root border element and hence the space on your left side and right side will be added by default. If you want to change the behavior you have to customize the RichTextBox template itself.
You can use this template and avoid the additional margin being added at left and right.
<ControlTemplate TargetType="RichTextBox">
<Grid Background="Transparent">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<ContentControl x:Name="ContentElement" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</Grid>
</ControlTemplate>
Regards, Mawy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With