为什么 TextTrimming 在第一个 TextBlock 上工作而不在第二个上工作?我在我的 xaml 上使用 LineBreaks,这是我需要显示的文本的一部分。
代码:
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid VerticalAlignment="Center">
<StackPanel>
<TextBlock TextTrimming="WordEllipsis" TextWrapping="Wrap" Width="20" Height="20" Background="Yellow">
1 2 3 4 5
</TextBlock>
<TextBlock TextTrimming="WordEllipsis" TextWrapping="Wrap" Width="20" Height="20" Background="Aqua">
1
<LineBreak/>
2
<LineBreak/>
3
<LineBreak/>
4
<LineBreak/>
5
</TextBlock>
</StackPanel>
</Grid>
输出: