需要在Windows Phone 7屏幕上显示大量文字
我想要在屏幕上显示大约 800 KB 的文本。有人可以让我知道这个问题的可能解决方案吗?
由于文本块的 2048X2048 限制,我已经尝试将文本拆分为多个文本块,并且还尝试了 http://blogs.msdn.com/b/priozersk/archive/2010/09/08/creating-scrollable-textblock-for-wp7.aspx< /a>.虽然这适用于 40 到 50 KB 的数据,但无法扩展到 800 KB 的大小。
我还尝试过使用列表框(如下面帖子的第一个解决方案中所述)。 wp7 - TextBlock 具有大量文本 - 巨大的内存使用 - 如何避免它?
这(如下所示)在 80-100KB 之前也有效,之后加载文本需要很长时间。
<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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Overflow7 中,我使用带有文本的 ListBox 方法 - 但我同意有时加载可能需要很长时间。
在 Iron7 中,我使用在 WebBrowser 控件中显示的 HTML 页面。
另一项建议是,如果您有大量文本,那么您可以查看 Kindle 如何显示文本 - Kindle for Windows Phone 7 使用的控件是什么
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
我知道这是一个老问题,但我想再添加一个解决方案。
http ://blogs.msdn.com/b/stankovski/archive/2013/08/27/yet-another-scrollable-textblock-for-windows-phone.aspx
为了完成我的任务,我封装了“拆分” 逻辑到一个单独的类中,该类生成字符串列表形式的输出。然后,您可以将该列表绑定到您最喜欢的 ListBox 控件,瞧,您就有了一个巨大的文本块。分割逻辑已经针对性能进行了优化,因此您将获得比 Alex 的 ScrollableTextBlock 更好的处理时间。此外,由于您可以将列表绑定到任何支持虚拟化的 ListBox 控件,因此您将拥有更加保守的内存占用量。
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.