4
在C#我有以下几点:如何:转换匿名方法VB.NET
public static void StartAnimation(UIElement animatableElement, DependencyProperty dependencyProperty, double toValue, double animationDurationSeconds, EventHandler completedEvent)
{
double fromValue = (double)animatableElement.GetValue(dependencyProperty);
DoubleAnimation animation = new DoubleAnimation();
animation.From = fromValue;
animation.To = toValue;
animation.Duration = TimeSpan.FromSeconds(animationDurationSeconds);
//// HERE ----------------------------------------------------
animation.Completed += delegate(object sender, EventArgs e)
{
//
// When the animation has completed bake final value of the animation
// into the property.
//
animatableElement.SetValue(dependencyProperty,
animatableElement.GetValue(dependencyProperty));
CancelAnimation(animatableElement, dependencyProperty);
if (completedEvent != null)
{
completedEvent(sender, e);
}
};
我有一些问题想匿名方法转换为VB.NET。
我的变种会
AddHandler animation.Completed,
Function(sender As Object, e As EventArgs) As Boolean
' '
' When the animation has completed bake final value of the animation '
' into the property. '
'
animatableElement.SetValue(dependencyProperty, animatableElement.GetValue(dependencyProperty))
CancelAnimation(animatableElement, dependencyProperty)
completedEvent(sender, e)
Return True
End Function
我加Function As Boolean
因为没有返回类型是不是一个函数,而是做一个“子”我不知道该怎么...
一些建议吗?
@moldovanu是的,应该工作。 – 2012-03-20 09:45:57
我试过了,但我想我还有其他一些让我迷失方向的错误。谢谢! ) – moldovanu 2012-03-20 09:56:12