Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1095991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:12:50+00:00 2026-05-17T00:12:50+00:00

I’m working on a windows phone 7 project, with silverlight, and i’m trying to

  • 0

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…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:12:51+00:00Added an answer on May 17, 2026 at 12:12 am

    Ok, I figured it out, and I think I also find a nice solution 🙂 IMHO

    I basically bound the Image.source to a proprerty of my class (that now extends INotifyPropertyChanged). But this gave me some issue about the transiction between images: since they were downloaded from internet there was a black images occurring between one images an the next one… but only the first time (i’m looping on a set of 4 images, looks like the video repeat), ’cause after that the images are cached.

    So, what I’ve done is to cache the images the first time, without displaying the right Image control, but displaying instead another Image control (or whatever else) which says to the user “I’m loading”.
    For handle this scenario I’ve created a custom event:

    public delegate void FramesPrefetchedEventHanlder();
    public event FramesPrefetchedEventHanlder FramesPrefetched;
    

    Now let’s take a look at the RetrieveImages method:

    private void RetrieveImages()
    {
        frameNumber = 0;
        currentCycle = 0;
        // set e very short interval, used for prefetching frames images
        timer.Interval = new TimeSpan(0, 0, 0, 0, 10);
        timer.Tick += (sender, e) => gotoNextImage();
        // defines what is going to happen when the prefetching is done
        this.FramesPrefetched += () => 
        {
            // hide the "wait" image and show the "movie" one
            imageLoading.Opacity = 0;
            image1.Opacity = 1;
            // set the timer with a proper interval to render like a short movie
            timer.Interval = new TimeSpan(0, 0, 0, 0, 400);
        };
    
        // when a frame is loaded in the main Image control, the timer restart
        image1.ImageOpened += (s, e) =>
        {
            if (currentCycle <= cycles) timer.Start();
        };
        // start the loading (and showing) frames images process
        gotoNextImage();            
    

    }

    Ok, now what we need to handle is the step by step loading of the image and communicate when we finished the prefetching phase:

    private void gotoNextImage()
    {
        timer.Stop();
        if (frameNumber < 4)
        {
            CurrentFrame = new System.Windows.Media.Imaging.BitmapImage(new Uri(cam.framesUrl[frameNumber]));
            frameNumber++;
        }
        else
        {
            // repeat the frame's sequence for maxCycles times
            if (currentCycle < maxCycles)
            {
                frameNumber = 0;
                currentCycle++;
                // after the first cycle through the frames, raise the FramesPrefetched event
                if (currentCycle == 1)
                {
                    FramesPrefetchedEventHanlder handler = FramesPrefetched;
                    if (handler != null) handler();
                }
                // step over to next frame
                gotoNextImage();
            }
        }
    }
    

    This works pretty fine to me… but since I’m new to Silverlight and Windows Phone 7 developement, any suggestion for improvement is welcome.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.