silverlight storyboard animation with rotatetransform code behind
i am trying to rotate an object from code behind. Code below:
Storyboard storyBoard = new Storyboard();
//Transform
RotateTransform rotate = new RotateTransform();
rotate.Angle = 45;
rotate.CenterX = 50;
rotate.CenterY = 20;
RodBorder.RenderTransform = rotate;
DoubleAnimation Anim = new DoubleAnimation();
Anim.Duration = new Duration(TimeSpan.FromMilliseconds(3000));
Anim.SetValue(Storyboard.TargetPropertyProperty, rotate);
Storyboard.SetTargetProperty(Anim, new PropertyPath("RenderTransform.Angle"));
Storyboard.SetTarget(Anim, RodBorder);
storyBoard.Children.Add(Anim);
storyBoard.Begin();
RodBorder is a Border which i want to rotate. The problem here is probably the PropertyPath, because i got an exception there.(System.Windows.PropertyPath cannot be set to type System.Windows.Media.Ro开发者_如何学CtateTransform) Any ideas are welcome, thank you for your help.
Try Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Rotation)"
.
You can always verify syntax by building sample animation in Blend.
精彩评论