margin text in TextBlock

user572844 picture user572844 · Jan 19, 2011 · Viewed 17.4k times · Source

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

Answer

alpha-mouse picture alpha-mouse · Jan 19, 2011

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

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