故事板可以执行自定义功能吗?

时间:2017-03-09 12:11:52

标签: c# wpf

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
}

0 个答案:

没有答案