为什么TextTrimming在第一个TextBlock上工作而不是在第二个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>
输出:

发布于 2014-08-29 10:27:07
你误解了它对trim的意义。修剪处理线的长度。您的第二个例子有很短的行长,但是有很多行。这与长线长度不同。
因此,修剪不是你所需要的。
https://stackoverflow.com/questions/25561356
复制相似问题