Storyboard
的常见用法是在不同的BeginTime
执行多个动画,即:
Storyboard m_storyboard = new Storyboard();
var fadeInAnimation = new DoubleAnimation(1d, TimeSpan.FromSeconds(3));
fadeInAnimation.BeginTime = TimeSpan.FromSeconds(1);
Storyboard.SetTarget(fadeInAnimation, grid);
Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath(Grid.OpacityProperty));
m_storyboard.Children.Add(fadeInAnimation);
var fadeOutAnimation = new DoubleAnimation(1d, TimeSpan.FromSeconds(3));
fadeOutAnimation.BeginTime = TimeSpan.FromSeconds(1);
Storyboard.SetTarget(fadeOutAnimation, label);
Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(Label.OpacityProperty));
m_storyboard.Children.Add(fadeOutAnimation);
m_storyboard.Begin();
但是我想设置Storyboard
,以便它可以在指定的BeginTime
调用我的自定义函数 - 是否可能?
public void CustomFunction()
{
// do something
}