【问题标题】:margin text in TextBlockTextBlock 中的边距文本
【发布时间】:2011-06-11 17:34:12
【问题描述】:

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>

结果在这里:

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

现在:|Chatuje 到 |_Chatuje

我想在 TextBlock 的左侧有一些空闲空间。

可用空间 TextOfTextBlock

没有

TextOfTextBlock

【问题讨论】:

    标签: wpf margin textblock alignment


    【解决方案1】:

    你需要在你的风格中设置Padding。像这样的

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

    【讨论】:

      【解决方案2】:

      看起来您需要设置 Padding 而不是 Margin。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-06-17
        • 2014-11-21
        • 1970-01-01
        • 2014-05-02
        • 1970-01-01
        • 1970-01-01
        • 2014-05-30
        • 1970-01-01
        相关资源
        最近更新 更多