Search code examples
windows-phone-7textblock

Book Reading Experience in WP7


I am trying to simulate the experience of reading a book in WP7. I basically have text I need to display in a textblock, enough to fill the page and allow the user to flip to the next page by swiping the finger across the screen. I am running into a few issues and I'd like to see if anyone has come across this or has a better idea:

  • the text I have is much longer than what I can fit on a single page, so I need to put only enough text in the textblock, font size and style are variable so I cannot build fixed pages. Any idea on how to truncate the text at the right length? Everything I could come up with is fairly computational intensive, e.g. add words and measure the textblock until it exceeds a preset size, then paint it
  • wp7 textblock lacks support for text justification, so I was wondering if anybody came across good WPF/SL/WP7 techniques for justifying text with variable char width

right now I am looking into having a series of textblocks, one line tall, one after the other in a stackpanel, enough to fill the screen and individually justified, hopefully not too resource intensive.

I will let you know what I find.

thank you


Solution

  • This seems to be quite a common question.

    I recommend:

    On your proposal, I think using multiple <Run>s inside a single multiline <TextBlock> is pretty much the same resource usage as putting multiple lines on a single page - so your approach should be OK.