Question

In my WP8 application I have a UserControl with an active Storyboard animation that makes that UserControl to move in a desired direction. At some point during that animation I programmatically add second UserControl to the scene.

The problem is that second, dynamically added UserControl contains a lot of elements inside and takes substantial time to render. While it loads, the UI is being blocked for about 50 milliseconds on my phone and the glitch in first UserControl's Storyboard animation is very noticable.

Question is what can I do about it? Should I somehow run animation in a different thread? If so then some general examples/links/manuals will help a lot because I'm not too versed in threads business. If that's not an option then I'd like to hear whatever can help me here.

Was it helpful?

Solution

I wouldn't advise threading on windows-phone; also you should avoid threading if you have data that needs to be shared between threads. It can be done but it's not easy.

If possible I would pre-load your user controls (or group of controls) and then show/hide them as they are needed. That should prevent the glitch you are seeing. If you need help with how to preload please post some example of how you are dynamically loading your controls and we may be able to assist you.

If you do need to do multi-threading I would advise using a background worker more details here:

http://msdn.microsoft.com/en-us/library/windowsphone/develop/cc221403(v=vs.105).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top