title: Want to have a slideshow of images on button click in Windows Phone 7
body: <p>I have stack of images in a grid and i want to implement a slide show for it.I am using <strong>Microsoft VS 2010 Express Edition for Windows phone</strong> for implemenitng this.Can someone help ? The code is :</p>
  
  <pre><code> using System;
   using System.Collections.Generic;
  
   using System.Windows.Threading;
  
    namespace swipe
   {
   public partial class MainPage : PhoneApplicationPage
  {
   // private DispatcherTimer tmr = new DispatcherTimer();
  
  private List&lt;string&gt; images = new List&lt;string&gt;();
  
  private int imageIndex = 0;
  
  public MainPage()
  {
      InitializeComponent();
  
      Loaded += new RoutedEventHandler(MainPage_Loaded);
  }
  
  void MainPage_Loaded(object sender, RoutedEventArgs e)
  {
     // tmr.Interval = TimeSpan.FromSeconds(5);
     // tmr.Tick += new EventHandler(tmr_Tick);
  
      LoadImages();
  
      ShowNextImage();
  }
  
  private void LoadImages()
  {
      images.Add("/images/Hydrangeas.jpg");
      images.Add("/images/Jellyfish.jpg");
      images.Add("/images/Koala.jpg");
      images.Add("/images/Tulips.jpg");
  }
  
  private void ShowNextImage()
  {
     // String bi = new BitmapImage(new Uri(images[imageIndex], UriKind.Relative));
  
      myImg.Source = new BitmapImage(new Uri(images[imageIndex], UriKind.Relative));
  
      imageIndex = (imageIndex + 1) % images.Count;
     }
  
     //void tmr_Tick(object sender, EventArgs e)
     //{
     //    ShowNextImage();
     //}
  
   protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
     {
      //if (!tmr.IsEnabled)
      //{
      //    tmr.Start();
      //}
  
      base.OnNavigatedTo(e);
   }
  protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
  {
      //tmr.Stop();
  
      base.OnNavigatedFrom(e);
  }
  
  private void Play_Click(object sender, RoutedEventArgs e)
  {
      ShowNextImage();
  }
  
   }
   }
  </code></pre>