Silverlight 动画效果1 -- 旋转
效果如下:
代码如下:
Storyboard sb,sb2; PlaneProjection pp; private void button1_Click(object sender, RoutedEventArgs e) { if (this.Projection == null) { this.Projection= pp = new PlaneProjection { RotationY=0 //--Y轴角度为0 }; } if (sb == null) { sb = new Storyboard(); DoubleAnimation da = new DoubleAnimation(); Storyboard.SetTarget(da, this.Projection); Storyboard.SetTargetProperty(da, new PropertyPath("RotationY"));//--旋转Y轴 sb.Children.Add(da); da.From = 0;//--从0度开始 da.To = 90; //--旋转90度 da.Duration = TimeSpan.FromSeconds(0.5); //时间0.5s sb.Completed += new EventHandler(sb_Completed);//转完一半开始别一半 } sb.Begin();//开始 } void sb_Completed(object sender, EventArgs e) { if (sb2 == null) { sb2 = new Storyboard(); DoubleAnimation da = new DoubleAnimation(); Storyboard.SetTarget(da, this.Projection); Storyboard.SetTargetProperty(da, new PropertyPath("RotationY")); sb2.Children.Add(da); da.From = 270;//从270度开始 da.To = 360;//到360度 da.Duration = TimeSpan.FromSeconds(0.5); sb2.Completed += new EventHandler(sb2_Completed); } this.Title = this.Title == "测试一" ? "测试二" : "测试一"; sb2.Begin(); } void sb2_Completed(object sender, EventArgs e) { }