Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Paragraph Margin in Windows Phone 8 XAML?

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.

like image 500
Lessneek Avatar asked Sep 01 '13 15:09

Lessneek


1 Answers

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

like image 64
Mawy Avatar answered Oct 07 '22 01:10

Mawy