个人资料

跳过导航链接首页 > 博客列表 > 博客正文

UWP/WPF使用C#代码设置关键帧动画

分类:


LinearDoubleKeyFrame lf1 = new LinearDoubleKeyFrame
				{
					KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 0, 0)),
					Value = 1
				};
				LinearDoubleKeyFrame lf2 = new LinearDoubleKeyFrame
				{
					KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0,0,500)),
					Value = 0.5
				};
				LinearDoubleKeyFrame lf3 = new LinearDoubleKeyFrame
				{
					KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 1, 0)),
					Value = 1
				};
				LinearDoubleKeyFrame lf4 = new LinearDoubleKeyFrame
				{
					KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 1, 500)),
					Value = 0.5
				};
				LinearDoubleKeyFrame lf5 = new LinearDoubleKeyFrame
				{
					KeyTime = KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0, 2, 0)),
					Value = 0
				};

				var ani_kf = new DoubleAnimationUsingKeyFrames();
				ani_kf.KeyFrames.Add(lf1);
				ani_kf.KeyFrames.Add(lf2);
				ani_kf.KeyFrames.Add(lf3);
				ani_kf.KeyFrames.Add(lf4);
				ani_kf.KeyFrames.Add(lf5);

				popin = new Storyboard();
				Storyboard.SetTarget(ani_kf, ShowText);
				Storyboard.SetTargetProperty(ani_kf, "Opacity");
				
				popin.Children.Add(ani_kf);


admin
最初发表2019/4/3 1:26:59 最近更新2019/4/3 1:27:18 300
为此篇作品打分
10
   评论