WPF虚拟化画布 [英] WPF Virtualizing a Canvas

查看:381
本文介绍了WPF虚拟化画布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一系列在Canvas内部生成的矩形,它们按照这个顺序嵌套。ScrollView> Canvas> VirtualizingStackPanel> XAML中的矩形。

We have a series of rectangles produced inside a Canvas and they are nested in this order ScrollView>Canvas>VirtualizingStackPanel>Rectangles in the XAML.

似乎有关于微软的一些信息,在什么情况下支持虚拟化,并且在不是没有错误抛出的情况下,它只是像一个标准StackPanel对待它。

There seems to be little information on Microsoft about under what senarios Virtualization is supported, and in cases where it isn't no error is thrown, it merely treats it like a standard StackPanel.

由于我们的视图在屏幕上大约有60个矩形,在整个画布上总共大约800个,加载时间大约5分钟是不可接受的缓慢。

Given that our view has roughly 60 rectangles on the screen at any one time out of a total of about 800 on the whole canvas the loading times of about 5 minutes are unacceptably slow.

我们已经尝试删除ScrollView没有效果(除去滚动条的性能没有改善),并删除一些其他嵌套元素,净效果似乎是没有显示,或其显示,但仍然缓慢。

We have already tryed removing the ScrollView to no effect ( other than removing the scroll bars the performance didn't improve), and removing some of the other nesting elements, the net effect seems to be either nothing is displayed, or its displayed but still slow.

到目前为止,我发现的最好的解决方案一个免费的商品代码VirtualizedCanvas但是它非常有限,并且不支持任何嵌套在它里面,因此唯一的输入是一个UI元素的集合。

The best solution I've found so far a sample piece of free ware code VirtualizedCanvas but its very very limited and doesn't support anything nested inside it, infact the only input it takes is a collection of UI Elements.

这个解决方案基本上忽略了数据绑定并且需要你将一个完整的Canvas传递给它,这会使我们现有的所有代码和转换器变得无用,并且是重大的返工工作。

This solution basically ignores the databinding and requires a you to pass a completed Canvas back to it, this renders all our existing code and converters pretty useless, and would be major rework to implement.

推荐答案

查看这个例子:

http://blogs.msdn.com/jgoldb/archive/2008/03/08/performant-virtualized-wpf-canvas.aspx

我在这里提出了类似的问题:资源和指南WPF中的UI虚拟化

I've asked a similar question on here: Resources and guides to UI virtualization in WPF

这篇关于WPF虚拟化画布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆