3
如果我有这样的代码:使用FormattedText对象,我如何知道我的文本实际上显示了多少?
FormattedText text = new FormattedText(sTheBook,
System.Globalization.CultureInfo.CurrentUICulture,
System.Windows.FlowDirection.LeftToRight,
new Typeface("Times New Roman"),
13, Brushes.Black);
text.MaxTextWidth = 300;
text.MaxTextHeight = 600;
text.TextAlignment = TextAlignment.Justify;
dc.DrawText(text, new Point(10, 0));
...那么,如果是长,只有一些我传递(通过sTheBook)的文本将显示在屏幕上。我需要知道显示了多少,所以我可以稍后显示其余的!我可以轻松测量大量文本,但通过反复渲染和重新渲染我的文本直到找到完全符合的部分,从而进行搜索似乎很愚蠢。
我会打开使用其他WPF文本呈现技术,如果它具有此功能。
谢谢!