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