I have around 800 KB of text which I want to display on the screen. Can somebody let me know possible solution to this?
Because of 2048X2048 limit of textblock, I have already tried splitting the text into multiple textblocks and also tried http://blogs.msdn.com/b/priozersk/archive/2010/开发者_如何学Go09/08/creating-scrollable-textblock-for-wp7.aspx. This, though works for data till 40 to 50 KB but doesn't scale to size of 800 KB.
I have also tried using Listbox (as mentioned in the first soluion in the below post). wp7 - TextBlock with a lot of text - huge memory usage - how to avoid it?
This (shown below) also works till 80-100KB and after that takes too long to load the text.
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ListBox x:Name="myListBox" Width="468" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock FontSize="20" Text="{Binding}" TextWrapping="Wrap" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
In Overflow7 I use the ListBox approach with text - but I agree it can take a long time to load sometimes.
In Iron7, I use an HTML page displayed within a WebBrowser control.
One other suggestion is that if you have a lot of text, then you could look at how Kindle displays text - What's the control used in Kindle for Windows Phone 7
I know this is an old question, however I wanted to add one more solution.
http://blogs.msdn.com/b/stankovski/archive/2013/08/27/yet-another-scrollable-textblock-for-windows-phone.aspx
To accomplish my task I have encapsulated the "splitting" logic into a separate class that produces the output as a List of strings. You can then bind that list to your favorite ListBox control and voila, you have a ginormous text block. The splitting logic has been optimized for performance so you'll get a much better processing time then ScrollableTextBlock by Alex. Also, since you can bind the list to any ListBox control that supports virtualization you will have a much more conservative memory footprint.
精彩评论