我正在尝试创建一个将委托作为其参数之一但它不起作用的方法。我究竟做错了什么?我在具有windowAnimation.Completed += new EventHandler(callback)
.
private void animateWindowWidth(Window window, double width, double duration, Delegate callback)
{
window.BeginInit();
window.Dispatcher.BeginInvoke(new Action(() =>
{
DoubleAnimation windowAnimation = new DoubleAnimation();
windowAnimation.Duration = new Duration(TimeSpan.FromSeconds(duration));
windowAnimation.From = window.Width;
windowAnimation.To = width;
windowAnimation.FillBehavior = FillBehavior.HoldEnd;
windowAnimation.Completed += new EventHandler(callback);
window.BeginAnimation(Window.WidthProperty, windowAnimation);
}), null);
window.EndInit();
}