Using the FormattedText object, how do I know how much of my text was actually displayed?

If I have a 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 part of the text that I transmitted (via sTheBook) will be displayed on the screen. I need to know how much was displayed, so I can show the rest later! I can easily measure the amount of text, but it seems silly to do a search by rendering and re-rendering the text over and over until I find a piece that exactly matches.

I could use a different WPF rendering technique if it has this feature.

Thank!

+3
source share
1 answer

, Width Height. " " .

0

Source: https://habr.com/ru/post/1746648/


All Articles