图片隔一段时间显示
images.ID 是一个时间的数组,每次循环时间都不一样,达到的效果,就是每张图片在规定的时间内显示?DispatcherTimer timer = new DispatcherTimer();
foreach (var images in list)
{
timer.Interval = TimeSpan.FromSeconds(images.ID);
Image img = new Image();
img.Width = 1350;
img.Height = 850;
img.Tag = images.AutoIncrease;
timer.Tick += (_, __) =>
{
timer.Stop();
string filename = "ms-appx:///Images/" + images.AutoIncrease + ".jpg";
img.Source = new BitmapImage(new Uri(filename));
sp1.Children.Add(img);
};
timer.Start();
}
--------------------编程问答-------------------- 什么问题呢?
下面的代码没有实现 LZ 想要的效果? --------------------编程问答-------------------- 我想要的效果就是;从服务器去图片和图片对应的时间,然后设定定时器,让每张图片显示对应的时间,然后再显示下一张,但是他不会切换图片 。 --------------------编程问答-------------------- 你这代码逻辑真够混乱的 --------------------编程问答--------------------
DispatcherTimer timer = new DispatcherTimer();
Int32 index = 0;
timer.Interval = TimeSpan.FromSeconds(0.1);
timer.Tick += () =>
{
timer.Stop();
if (index>=list.Length)
{
return;
}
index++;
timer.Interval = TimeSpan.FromSeconds(list[index].ID);
string filename = "ms-appx:///Images/" + list[index].AutoIncrease + ".jpg";
image.Source = new BitmapImage(new Uri(filename));
image.Tag = list[index].AutoIncrease;
timer.Start();
};
--------------------编程问答-------------------- 代码我试过了,还是不行
<Grid Background="Transparent">
<Image x:Name="image"
Width="1350"
Height="850"/>
</Grid>
补充:移动开发 , Windows Phone