Windows Phone 7中的图像旋转动画

时间:2011-10-14 08:00:39

标签: windows-phone-7

在拍摄图像时,我希望图像旋转。我在网上查了一下,但似乎没什 那么怎么做呢? 任何帮助将不胜感激。

更新
我找到了解决方案,看起来非常简单。以下代码执行图像旋转动画的技巧:

            Duration duration = new Duration(TimeSpan.FromSeconds(2));
            Storyboard sb = new Storyboard();
            sb.Duration = duration;

            DoubleAnimation da = new DoubleAnimation();
            da.Duration = duration;

            sb.Children.Add(da);

            RotateTransform rt = new RotateTransform();

            Storyboard.SetTarget(da, rt);
            Storyboard.SetTargetProperty(da, new PropertyPath("Angle"));
            da.To = 360;

            Search.RenderTransform = rt;
            Search.RenderTransformOrigin = new Point(0.5, 0.5);

            sb.Begin();

1 个答案:

答案 0 :(得分:4)

以下代码可以旋转图像:

            Duration duration = new Duration(TimeSpan.FromSeconds(2));
            Storyboard sb = new Storyboard();
            sb.Duration = duration;

            DoubleAnimation da = new DoubleAnimation();
            da.Duration = duration;

            sb.Children.Add(da);

            RotateTransform rt = new RotateTransform();

            Storyboard.SetTarget(da, rt);
            Storyboard.SetTargetProperty(da, new PropertyPath("Angle"));
            da.To = 360;

            Search.RenderTransform = rt;
            Search.RenderTransformOrigin = new Point(0.5, 0.5);

            sb.Begin();