Problem with TextBlock in ScrollViewer
I'm writing a WP7 app and on a certain page I have a TextBlock with textwrapping. This TextBlock gets its text through binding. I placed a ScrollViewer around the TextBlock for when there are too many lines of text. Here's an example:
<ScrollViewer Margin="0,128,0,0" Name="Scroller">
<TextBlock x:Name="ItemContent" TextWrapping="Wrap" Text="{Binding Content}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</ScrollViewer>
Now when I开发者_如何学运维 scroll to the end of the text, I still can scroll down half a page or more. I have trimmed my text both sides, so that's not the problem either. Is there a way to fix this?
Thanks!
There is limitation on all UIElements that they can't be more than 2048px in either dimension. This is to avoid excessive memory use when creating much more UI than can fit on the screen at once.
I'd advice splitting the text over multiple TextBlocks.
One alternative is to embed the text in a WebBrowser control but this can provide a substandard user experience.
For an example on alternative method see http://blogs.msdn.com/b/priozersk/archive/2010/09/08/creating-scrollable-textblock-for-wp7.aspx
精彩评论