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();

横移动画!

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。