TextBlock中的边距文本

7

在TextBlock控件中可能有边距文本吗?

我的TextBlock控件样式在这里:

<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>

结果在这里:

alt text

例如,我想在 TextBlock 中对文本进行对齐或设置边距。

现在:|Chatuje to |_Chatuje

我想在 TextBlock 的左侧留出一些空白。

TextOfTextBlock 的自由空间

没有

TextOfTextBlock

2个回答

25

您需要在样式中设置Padding。类似以下代码:

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

4
看起来您需要设置内边距而不是外边距。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接