2
私はC#でアニメーションを作成する方法を学習しています。私は簡単に関数を作成することができていますイージング関数をプログラムで作成するC#
test(someObject, FrameworkElement.MarginProperty);
/// <summary>
/// animate margin of an object
/// </summary>
/// <param name="target">what object do you whant to animate?</param>
/// <param name="property">what property do you want to animate</param>
public void test(DependencyObject target, DependencyProperty property)
{
ThicknessAnimation animation = new ThicknessAnimation();
animation.To = new Thickness(0,0,0,0); // final value
//animation.From = new Thickness(50,50,50,50);
//make animation last 5 seconds
animation.BeginTime = TimeSpan.FromSeconds(0);
animation.Duration = TimeSpan.FromSeconds(5);
// set the ease function
BounceEase b = new BounceEase();
animation.EasingFunction = b;
//note that I would like to add an easeIn function
//start animating
Storyboard.SetTarget(animation, target); // what object will be animated?
Storyboard.SetTargetProperty(animation, new PropertyPath(property)); // what property will be animated
Storyboard sb = new Storyboard();
sb.Children.Add(animation);
sb.Begin();
}
注:私は例えば、オブジェクトの余白をアニメーション化していた場合、私はそれは余裕だアニメーション化するには、以下のメソッドを使用します。しかし、EaseInOutイージング関数を作成したい場合はどうすればよいですか? EaseInOutアプローチを使用してオブジェクトをアニメートするには、テストメソッドに何を追加する必要がありますか?