8,731
社区成员
发帖
与我相关
我的任务
分享
public partial class MainWindow : Window
{
private Storyboard sb;
public MainWindow()
{
InitializeComponent();
load();
sb.Begin();
}
//载入
private void load()
{
sb = new Storyboard();
ObjectAnimationUsingKeyFrames oauf = new ObjectAnimationUsingKeyFrames();
//加载一些图片,添加进去
for (int i = 305; i < 315; i++)
{
string picName = "imgres/" + String.Format("{0:D3}", i) + ".png";
BitmapImage bmp = new BitmapImage(new Uri(picName, UriKind.Relative));
DiscreteObjectKeyFrame dokf = new DiscreteObjectKeyFrame(bmp, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(250)));
oauf.KeyFrames.Add(dokf);
}
//这里有很大的疑惑,这里对么
PropertyPath path = new PropertyPath("Image.Sourse");
Storyboard.SetTargetProperty(oauf, path);
Storyboard.SetTarget(oauf, img);
sb.Children.Add(oauf);
}
<Image Stretch="None" Name="img"/>