首页 > 代码库 > Silverlight代码编写对控件的PlaneProjection.RotationY属性控制动画

Silverlight代码编写对控件的PlaneProjection.RotationY属性控制动画

         Canvas c;     void btnDraw_Click(object sender, RoutedEventArgs e)        {            Storyboard story = new Storyboard();            DoubleAnimation yAnimation = new DoubleAnimation();            yAnimation.From = 0.5;            yAnimation.To = 100;            yAnimation.Duration = new Duration(TimeSpan.FromSeconds(5));            PlaneProjection pp = (PlaneProjection)c.Projection; //找到注册的属性              Storyboard.SetTarget(yAnimation, pp);            Storyboard.SetTargetProperty(yAnimation, new PropertyPath(PlaneProjection.RotationYProperty));            story.Children.Add(yAnimation); story.Begin();         }
 void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            c = new Canvas();
            c.Height = 200;
            c.Width = 200;
            c.Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0));
            PlaneProjection pp = new PlaneProjection() { RotationY = 0 };//这里已经指定了RotationY
            c.Projection = pp;
            LayoutRoot.Children.Add(c);
        }

以上代码实现了对控件RotationY属性的动画控制!

 

// 在此处添加事件处理程序实现。            Storyboard sboard1 = new Storyboard();                        DoubleAnimation daAngle1 = new DoubleAnimation();            sboard1 .Completed+=new EventHandler(sboard1_Completed);            Storyboard.SetTarget(daAngle1, Grid1  );            Storyboard.SetTargetProperty(daAngle1, new PropertyPath("(canvas.left)"));            daAngle1.From = 0;            daAngle1.To = -850;            daAngle1.Duration = TimeSpan.FromSeconds(1);            sboard1.Children.Add(daAngle1);            sboard1.Begin();

横移动画!

Silverlight代码编写对控件的PlaneProjection.RotationY属性控制动画