设置 ScaleTransform.ScaleXProperty 动画的代码

来源:互联网 发布:华道数据工作怎么样 编辑:程序博客网 时间:2024/05/21 00:21
2009-08-18 21:14:47 来自:逆风的蝴蝶 浏览数:21
NameScope.SetNameScope(this, new NameScope()); 

            Button button1 = new Button(); 
            button1.Width = 100; 
            button1.Height = 100; 
            button1.Content = "fds"; 
            button1.Name = "button1"; 
            c1.Children.Add(button1); 
            button1.RenderTransform = new TranslateTransform();                    
            this.RegisterName(button1.Name, button1); 
            Storyboard story = new Storyboard(); 
            story.AutoReverse = true; 
            story.RepeatBehavior = RepeatBehavior.Forever; 
            DoubleAnimation yAnimation = new DoubleAnimation();//子动画 
            yAnimation.From = 0; 
            yAnimation.To = 100; 
            yAnimation.Duration = new Duration(TimeSpan.FromSeconds(10)); 


          DependencyProperty[] propertyChain = 
              new DependencyProperty[] { Button.RenderTransformProperty,                    
                  TransformGroup.ChildrenProperty, 
                  ScaleTransform.ScaleXProperty}; 
            string thePath = "(0).(1)[0].(2)"; 
            Storyboard.SetTargetName(yAnimation, button1.Name); 
            Storyboard.SetTargetProperty(yAnimation, new PropertyPath(thePath, propertyChain)); 
  
            story.Children.Add(yAnimation);          
            story.Begin(this); 

调试时报错 {"路径“(0).(1)[0].(2)”中的“Children”属性值指向“System.Windows.Media.TransformCollection”的不可变实例。"}
原创粉丝点击