SetTargetPropertyあたりのプログラミングで、どのように表記すればいいのかが分からず難しい。
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
namespace wpfsbtest1
{
/// <summary>
/// Window1.xaml の相互作用ロジック
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
Play1();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
translateTransform1.BeginAnimation(TranslateTransform.XProperty, daukf);
}
Storyboard myStoryboard1 = new Storyboard();
DoubleAnimationUsingKeyFrames daukf = new DoubleAnimationUsingKeyFrames();
TranslateTransform translateTransform1 = new TranslateTransform();
private void Play1()
{
textBox1.RenderTransform = translateTransform1;
SplineDoubleKeyFrame sdkf1 = new SplineDoubleKeyFrame(0, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 0)));
SplineDoubleKeyFrame sdkf2 = new SplineDoubleKeyFrame(200, KeyTime.FromTimeSpan(new TimeSpan(0, 0, 3)));
daukf.BeginTime = new TimeSpan(0, 0, 0);
daukf.Duration = new TimeSpan(0, 0, 3);
daukf.KeyFrames.Add(sdkf1);
daukf.KeyFrames.Add(sdkf2);
Storyboard.SetTargetName(daukf, this.textBox1.Name);
Storyboard.SetTargetProperty(daukf, new PropertyPath(TranslateTransform.XProperty));
myStoryboard1.Children.Add(daukf);
}
}
}