开发者

silverlight storyboard animation with rotatetransform code behind

开发者 https://www.devze.com 2023-03-23 20:42 出处:网络
i am trying to rotate an object from code behind. Code below: Storyboard storyBoard = new Storyboard();

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消