How do I change the background image of a Windows phone app

81 Views Asked by At

I am developing an WP8 app and would like to change the background image with several images ; setting time as a variable and showing images in C#,

1

There are 1 best solutions below

4
On BEST ANSWER

You can use DispatcherTimer class in order to change the images with respect to time.

Let me suggest you the easiest way. Name your images as numbers like 1.jpg,2.jpg,3.jpg etc and put them inside a folder.

Now you can use either random number class to pick the images in random order or can use the following method to get the sequentially:

DispatcherTimer picture_timer = new DispatcherTimer();
Random rnd = new Random();

picture_timer .Interval = new TimeSpan(0, 0, 3);
                   picture_timer .Tick += timer_Tick;
                   picture_timer .Start();

 void timer_Tick(object sender, object e)
        {
int num = rnd.Next(1, 13); // creates a number between 1 and 12
string image_source = "/Assets/"+num+".jpg";

}