开发者

Issues with rendering a large tiled map in WPF

What is the best way to manage a very large amount of images (10,000+) in WPF? This is for a 2d tile map editor similar to this : http://www.mapeditor.org/ .

At the moment i 开发者_开发技巧have a canvas with all tiles as an image and a list box which contains the different images to choose from. Each tile is added to the canvas as children and then stored in a list for later access. You paint into the canvas by setting the Source property of a tile to the one selected in the listbox. It works well with around 50x50 tile maps but anything above that causes loading delays, in general slow application.

Any suggestions on this? Would QT maybe be more suited instead of wpf?

Thanks in advance


Check out Implementing virtualized panel series of articles.

Virtualized panels are efficient, because:

  • Only the displayed elements (and a few extra around the borders to enable smooth scrolling) are in the memory (and rendered).

  • Elements are reused, instead of being repeatedly created and discarded - an old cell is simply filled with new content (supplied with new DataContext) and used in new location.

You might also try to use WPF's DataGrid for this, it supports virtualization out of the box and is essentially what are you trying to do.

WPF is certainly able to do this, if implemented properly (if you can do that in JavaScript, you can certainly do it in WPF as well).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜