Windows phone 7 制作幻灯片放映wp7

Windows phone 7 制作幻灯片放映wp7,windows-phone-7,timer,slide,Windows Phone 7,Timer,Slide,我必须用幻灯片展示存储在我的独立存储中的图像。。但是我是windows phone的初学者,我有一些困难。。我已经知道如何显示图像,或在屏幕上显示图像。。但是我想每幅图片展示2秒钟。。有一些函数可以定义复制的时间?有什么例子吗 IsolatedStorageFileStream stream = new IsolatedStorageFileStream(name_image, FileMode.Open, myIsolatedStorage);

我必须用幻灯片展示存储在我的独立存储中的图像。。但是我是windows phone的初学者,我有一些困难。。我已经知道如何显示图像,或在屏幕上显示图像。。但是我想每幅图片展示2秒钟。。有一些函数可以定义复制的时间?有什么例子吗

 IsolatedStorageFileStream stream = new IsolatedStorageFileStream(name_image,       FileMode.Open, myIsolatedStorage);

                    var image = new BitmapImage();
                    image.SetSource(stream);
                    image1.Source = image;

这就是我打开图像的方式。我有一个有5个图像名称的foreach,然后我打开每一个。。但是我想看2秒钟的图像。

您可以让当前线程睡眠2秒钟:

System.Threading.Thread.Sleep(2000);

作为foreach body中的最后一句话。它不是很整洁,但它可以完成任务。

更好的方法是使用
反应式扩展

首先看看我的答案。它会告诉您需要哪些DLL以及一些有用的链接

基本上,您需要将图像存储在一个集合中,然后使用
Rx
GenerateWithTime
)基于集合创建一个具有时间维度的可观察序列。最后,调用一个方法来添加一个图像并将其订阅到可观察序列中

这是一个有效的例子

private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
    // create a collection to store your 5 images
    var images = new List<Image>
        {
            new Image() { Source = new BitmapImage(new Uri("/ApplicationIcon.png", UriKind.Relative)), Width = 120, Height = 120 },
            new Image() { Source = new BitmapImage(new Uri("/ApplicationIcon.png", UriKind.Relative)), Width = 120, Height = 120 },
            new Image() { Source = new BitmapImage(new Uri("/ApplicationIcon.png", UriKind.Relative)), Width = 120, Height = 120 },
            new Image() { Source = new BitmapImage(new Uri("/ApplicationIcon.png", UriKind.Relative)), Width = 120, Height = 120 },
            new Image() { Source = new BitmapImage(new Uri("/ApplicationIcon.png", UriKind.Relative)), Width = 120, Height = 120 }
        };

    // create a time dimension (2 seconds) to the generated sequence
    IObservable<Image> getImages = Observable.GenerateWithTime(0, i => i <= images.Count - 1, i => images[i], _ => TimeSpan.FromSeconds(2), i => ++i);

    // subscribe the DisplayOneImage handler to the sequence
    getImages.ObserveOnDispatcher().Subscribe(DisplayOneImage);
}

private void DisplayOneImage(Image image)
{
    // MyItems is an ItemsControl on the UI
    this.MyItems.Items.Add(image);
}
private void主页\u已加载(对象发送方、路由目标方)
{
//创建一个集合来存储您的5幅图像
var images=新列表
{
new Image(){Source=new-BitmapImage(新Uri(“/applicationion.png”,UriKind.Relative)),宽度=120,高度=120},
new Image(){Source=new-BitmapImage(新Uri(“/applicationion.png”,UriKind.Relative)),宽度=120,高度=120},
new Image(){Source=new-BitmapImage(新Uri(“/applicationion.png”,UriKind.Relative)),宽度=120,高度=120},
new Image(){Source=new-BitmapImage(新Uri(“/applicationion.png”,UriKind.Relative)),宽度=120,高度=120},
新图像(){Source=new-BitmapImage(新Uri(“/ApplicationIcon.png”,UriKind.Relative)),宽度=120,高度=120}
};
//为生成的序列创建时间维度(2秒)
IObservable getImages=Observable.GenerateWithTime(0,i=>i images[i],=>TimeSpan.FromSeconds(2),i=>++i);
//向序列订阅DisplayOneImage处理程序
getImages.ObserveOnDispatcher().Subscribe(DisplayOneImage);
}
私有void DisplayOneImage(图像图像)
{
//MyItems是UI上的Items控件
this.MyItems.Items.Add(图像);
}
希望这有帮助。:)