I'm working on a project that requires doing sprite based animation in XAML / C# for a windows store app. I've worked out a method for displaying the animation, but it causes flickering during the initial load of the images. The method I used basically involves creating a class which subclasses canvas that loops through all children during the its CompositionTarget.Rendering event. If any of the child objects are of type SpriteImage (another class I created that subclasses content control and is a container for the image control that displays the current frame) it calls the update method so that the SpriteImage may display the appropriate bitmap image for the current frame.
I have shared the sample project at the following link: Sample Sprite Animation Project for VS 2012 and Windows 8.
It seems that after the animation has completed one iteration and all of the BitmapImages have been loaded from the source URIs, the animation runs smoothly. I suspect that the BitmapImage is not loaded until the Image who is using it for the source is loaded.
So I was hoping to get two things from the community:
Anyone have any good ideas on how I can use preload those images so that the flicker does not happen?
Anyone have any good ideas on how to get these into a sprite sheet so that I do not have to have use separate files? I haven't found a good way to do it with Win8 XAML / C#.
Any help is greatly appreciated.