简体   繁体   中英

Poor StackPanel performance with WPF

I have an application which runs fullscreen on a high resolution display (1920x1080). About 25% of the screen is a StackPanel that scrolls images across the screen. (the X position is animated with double animation)

The scroll is very laggy and jumpy, and with visible tearing. This is running on a brand new high-end gaming laptop, running Win7 64bit.

I don't understand why the performance is so poor. Am I doing something wrong? Does this kind of animation run on the CPU or GPU? Is there a smarter way to scroll images across the screen?

WPF can be hardware-accelerated, but only on newer video card drivers. Some of the onboard, out of box drivers, will default back to software rendering, which can feel really slow and clunky. As for the tearing, that's a normal video card setting, called V-Sync. I would try updating the video card drivers to a proprietary driver (nVidia, AMD, etc.), and enabling vertical sync on the card.

You can check to see if it falls into software, or hardware rendering using the methods explained here .

If that doesn't resolve the issue, the only other possibility I can think of is your animation/rendering is not synced to the GUI.

See this msdn article for more details.

A trick that I've seen that can get around this issue is to place a 3D object on your page, view it side on and rotate it eg for 4 images have a cube with an image set to each side. Yes the rotation still requires GPU and processor time but it is taken care of internally by the WPF animation and so doesn't require interaction with code behind once set rolling.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM