WPF DoubleAnimation Codebehind-1-


XAMLだと、さすがに行数が多くなりすぎるので




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;

namespace WpfApplication1
{
///


/// MainWindow.xaml の相互作用ロジック
///

public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
// dAnime1.From = 0;
// dAnime1.To = 360;
// dAnime1.Duration = new Duration(TimeSpan.FromSeconds(3));
//// dAnime1.RepeatBehavior = RepeatBehavior.Forever;

RotateTransform Rotation1 = new RotateTransform();
rectangle1.RenderTransform = Rotation1;
button1.RenderTransform = Rotation1;

RotateTransform Rotation2 = new RotateTransform();
slider1.RenderTransform = Rotation2;
stackPanel1.RenderTransform = Rotation2;

DoubleAnimation dAnime1 = new DoubleAnimation(0, 360, new TimeSpan(0, 0, 3));
Rotation1.BeginAnimation(RotateTransform.AngleProperty, dAnime1);

DoubleAnimation dAnime2 = new DoubleAnimation(0, 360, new TimeSpan(0, 0, 6));
Rotation2.BeginAnimation(RotateTransform.AngleProperty, dAnime2);

}
}
}

XAML の場合↓
http://d.hatena.ne.jp/TYKYUNC/20110304/1299228580



AX

TYKYUNC index