Using a FormattedText object, how do I find out how much of my text was actually displayed?

Posted by Robert on Stack Overflow See other posts from Stack Overflow or by Robert
Published on 2010-05-22T02:26:19Z Indexed on 2010/05/22 2:30 UTC
Read the original article Hit count: 394

Filed under:
|
|

If I have code like this:

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));

...then, if it is long, only some of the text that I passed in (via sTheBook) will be displayed on the screen. I need to know how much was displayed so I can display the rest later! I can easily measure an amount of text, but it seems silly to do a search by rendering and re-rendering my text over and over until I find the piece that fits exactly.

Thanks!

© Stack Overflow or respective owner

Related posts about wpf

Related posts about c#