WPF sluggish rendering/animation performance?
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?开发者_如何学Go Is this really too much to ask from WPF?
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.
精彩评论