views:

169

answers:

1

I've been trying to animate around 1000 lines which are all added to a Canvas, and it is extremely slow to the extend that animation is not feasible at all. At first I thought it was probably because of all the calculations, but then I tried a very simple experiment. I generated around 1000 random lines and I tried to move them to new random coordinations using PointAnimations. I've basically ran this program on every combination of OS/Hardware that I could find and I can't even get more than 4 frames a second.

The source (and a bit more info) can be found at http://ali.shiravi.com/index.php/wpf-sluggish-rendering-performance/

Does anyone have any solutions to this? Is this really too much to ask from WPF?

+1  A: 

Here's how I handle a situation like that. Don't try to move the visible lines individually, just repaint the whole collection, but paint it to a bitmap, and then block-transfer that to the visible window.

If you repaint 1000 lines directly to the visible window, it could take 10-100 ms, and you will probably see flashing. But if you paint to a memory bitmap, it will probably take about the same amount of time, but it will not visibly flash, because the block-transfer to the screen is so fast.

Mike Dunlavey