views:

27

answers:

0

I've got an animation running on the main window (only window) of my WPF application. Problem is that this animation isn't running smoothly.

This animation was constructed in a separate, empty project and worked perfectly (nice and smooth) until I transferred it to my main application. Now you're probably thinking what is the application doing that is interrupting the dispatcher and slowing down the rendering of the animation?

Turns out that the application isn't doing anything. Through a process of elimination (commenting out large chunks of code) I've narrowed the problem down to the creation of my splashscreen. Seems that if I create a window (the splashscreen is a normal WPF window), display it for a couple of seconds, close it and then display my main window, the animation on the main window is jerky. If I take the splashscreen out of the equation the animation is rendered smoothly.

So, why does opening and closing another window before showing my main window cause the main windows animation to shudder?

I've reproduced the problem in a small demo that can be downloaded here http://dl.dropbox.com/u/9706535/AnimationDemo.zip

MainWindow.xaml.cs contains two lines that are commented out. Uncomment these and the animation becomes jerky. Leave them commented out and the animation runs fine.

Note that if you leave the lines commented out, run the application and close the "splashscreen" window (standard windows close button), the animation stops. Why? And why does resizing the main window cause the animation to start again?

Also this problem doesn't occur on .Net 4.0 (I'm using 3.5 SP1) which leads me to believe that something fruity is going on under the .Net hood.