2

我对 TextBlock 的问题是它有时会切断文本。下图是它下面的 xaml 的输出。第一个 TextBlock 应该包含 Défi 最大值,但最后一个 m 被截断。当我改变部分风格时,它会重新出现,但我需要它完全像这样。这可能是什么原因?

如您所见,TextBlock 有足够的空间,下图中 TextBlock 周围的边距是蓝色的。第二个 TextBlock 有一个额外的字符,导致 TextBlock 正确显示文本。(即使其中有拼写错误;-))

有效的 XHTML

<Window.Resources>
    <Style TargetType="TextBlock">
        <Setter Property="FontFamily" Value="Candara"/>
        <Setter Property="FontSize" Value="13"/>
        <Setter Property="FontWeight" Value="Regular"/>
        <Setter Property="Padding" Value="5"/>
        <Setter Property="Background" Value="Red"/>
        <Setter Property="TextWrapping" Value="Wrap"/>
        <Setter Property="TextAlignment"  Value="Center"/>
        <Setter Property="HorizontalAlignment" Value="Center"/>
        <Setter Property="VerticalAlignment" Value="Center"/>
        <Setter Property="Margin" Value="0"/>
    </Style>

    <Style TargetType="Grid">
        <Setter Property="Width" Value="87"/>
        <Setter Property="Height" Value="87"/>
        <Setter Property="Background" Value="Blue"/>
        <Setter Property="Margin" Value="1"/>
    </Style>
</Window.Resources>

<StackPanel Orientation="Horizontal">
    <Grid>
        <TextBlock>Défi maximum</TextBlock>
    </Grid>
    <Grid>
        <TextBlock>Défi maximume</TextBlock>
    </Grid>
    <Grid>
        <TextBlock>3x10</TextBlock>
    </Grid>
    <Grid>
        <TextBlock>4x10</TextBlock>
    </Grid>
</StackPanel>
4

1 回答 1

-1

减小字体大小或增加框宽度。

于 2012-09-05T08:56:50.627 回答