7
votes

Is it possible margin Text in TextBlock control ?

My style on textBlock control is here :

<Style x:Key="InfosStyle" TargetType="{x:Type TextBlock}">
    <Setter Property="FontSize" Value="13"/>
    <Setter Property="FontWeight" Value="Normal"/>
    <Setter Property="Height" Value="35"/>
    <Setter Property="VerticalAlignment" Value="Center"/>
    <Setter Property="TextAlignment" Value="Justify"/>
    <!--<Setter Property="BorderThickness" Value="1"/>-->
    <!--<Setter Property="BorderBrush" Value="#BFE3FE"/>-->
    <Setter Property="Background" Value="#BFE3FE"/>
    <Setter Property="Margin" Value="2,4,0,1" />
</Style>

Result is here:

alt text

For examole I would like align or set margin on text in textBlock.

Now: |Chatuje to |_Chatuje

I would like have some free space on left side in TextBlock.

Free space TextOfTextBlock

No

TextOfTextBlock

2

2 Answers

23
votes

You need to set Padding in your style. Something like this

<Setter Property="Padding" Value="10,0,0,0" />
3
votes

Looks like you need to set Padding instead of Margin.