Need to show large amount of text on windows phone 7 screen

限于喜欢 提交于 2019-12-22 22:26:07

问题


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/09/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>

回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/5442288/need-to-show-large-amount-of-text-on-windows-phone-7-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!