Windows Phone 8.1 旋转动画

network | | 访问(44)
<Button Content="会旋转的按钮" Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center"                   
                    RenderTransformOrigin="0.5 0.5" Background="Blue" Click="OnButtonClick">
    <Button.RenderTransform>
        <RotateTransform />
    </Button.RenderTransform>
</Button>
private void OnButtonClick(object sender, RoutedEventArgs args) {
    Button btn = sender as Button;
    RotateTransform rotateTransform = btn.RenderTransform as RotateTransform;
    DoubleAnimation anima = new DoubleAnimation();
    anima.From = 0;
    anima.To = 360;
    anima.Duration = new Duration(TimeSpan.FromSeconds(0.5));
    Storyboard.SetTarget(anima, rotateTransform);
    Storyboard.SetTargetProperty(anima, "Angle");
    Storyboard storyboard = new Storyboard();
    storyboard.Children.Add(anima);
    storyboard.Begin();
}