[英]TextBlock issue when long text and TextTrimming
I have a TextBlock with TextTrimming="CharacterEllipsis"
, TextWrapping="NoWrap"
and very long text about 140 000 symbols. 我有一个TextBlock,它带有
TextTrimming="CharacterEllipsis"
, TextWrapping="NoWrap"
和非常长的文本,大约有140000个符号。 I put this text into the TextBlock, and then the TextBlock shows this text as multiline control whith trimming in an each row. 我将此文本放入TextBlock中,然后TextBlock将此文本显示为多行控件,并在每一行中进行修整。
<Window x:Class="WpfApplication3.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>
<TextBlock x:Name="textBlock" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Width="500"/>
</Grid>
</Window>
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
string str = "q ";
for(int i = 0; i < 20000; i++) {
str += "qwetre ";
}
textBlock.Text = str;
}
}
Any ideas? 有任何想法吗? Is it bug of MS, or I can change this behaviour?
是MS的错误,还是我可以更改此行为?
The Textblock TextWrapping
property is by default set to NoWrap. 默认情况下,Textblock
TextWrapping
属性设置为NoWrap。
Therefore, unless you 因此,除非您
<LineBreak/>
tags with the text <LineBreak/>
标记 the text will always be displayed over one line only. 文本将始终仅显示在一行上。
@Mirimon I ran this project exactly as you have shown and I only see one row! @Mirimon我完全按照您显示的方式运行了这个项目,我只看到一行!
I have found answer on my question. 我已经找到问题的答案。 The TextBlock has this behaviour with 4.5 framework (I had install VS2012), I tried in on computer without VS2012, work correctly, only one row.
TextBlock在4.5框架(我已安装VS2012)中具有此行为,我在没有VS2012的计算机上尝试使用,正常工作,只有一行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.