Hi, I'm working on a windows phone 7 project, with silverlight, and i'm trying to show 4 images in sequence to give the user the feeling of a short movie. I have 4 urls pointing to 4 different jpeg images, and I'm using an Image control to show these jpeg in sequence. The way I'm trying to achieve this is by doing:
private void RetrieveImages()
{
image1.ImageOpened += new EventHandler<RoutedEventArgs>(image1_ImageOpened);
frameNumber = 0;
gotoNextImage();
}
void image1_ImageOpened(object sender, RoutedEventArgs e)
{
System.Threading.Thread.Sleep(400);
gotoNextImage();
}
private void gotoNextImage()
{
if (frameNumber < 4)
{
webBrowser1.Dispatcher.BeginInvoke(()=> {
image1.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri(cam.framesUrl[frameNumber]));
frameNumber++;
});
}
else
{
image1.ImageOpened -= image1_ImageOpened;
}
}
But this just don't work as expected. I'm sure I'm missing something about how to interact with the UI. Can anyone point me in the right direction? Which is the best way to achieve this?
Edited:
I'll explain better what's wrong with my code... probably it's unclear what happens. I don't get any error with my code, but I don't see the "movie effect" too. It just show 1 single image, without iterating between the image collection. I think it's a threading problem... kind of I'm not doing the right thing in the right thread to see the UI updating as expected...