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”的不可变实例。"}
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”的不可变实例。"}