I am working on Windows Phone 8.1 application and I got this issue:
I have a RichTextBlock
control which holds my text, if my control height is bigger than my screen I need to scroll line by line automaticly while the user reads the text.
Is there any way to determine the number of the lines in my RichTextBlock
or geometric calculation is the only way?
I've tried to iterate over the Blocks collection, but nothing seems to be relevant.
The only thing that I've came with is by using TextPointer.GetCharacterRect
function:
if(msgContainer.Blocks.Any())
{
var item = msgContainer.Blocks.FirstOrDefault();
var height = item.LineHeight;
var startRect = item.ContentStart.GetCharacterRect(LogicalDirection.Forward);
var lineHeight = startRect.Height;
var lineCount = (int)_fatAssTextMessage.ActualHeight / lineHeight;
}
But it isn't accurate - sometimes it misses by line or two since the int casting, and the division...
Any help will be appreciated