如何等到或知道 Xamarin Forms 中的多个动画何时完成?

How to wait until or know when multiple animations are completed in Xamarin Forms?

我有一个处理多个动画的代码。我想等到或知道多个动画是否完成。我目前正在使用 await Task.Delay(1000); 并将其设置为等于其中一个动画的最长持续时间。

下面是我的 C# 代码:

new Animation()
{
    { 0, 1, new Animation(a => dialogControl.FadeTo(1, 1000)) },
    { 0, 1, new Animation(a => dialogControl.ScaleTo(1, 1000)) },  
}.Commit(this, "Animation1");

await Task.Delay(1000);
Debug.WriteLine("Do some task after multiple animations are completed");

有没有等到所有动画都完成后才继续的?

来自 Commit

上的文档
public void Commit (Xamarin.Forms.IAnimatable owner, 
    string name, uint rate = 16, uint length = 250,
    Xamarin.Forms.Easing easing = default, 
    Action<double,bool> finished = default, 
    Func<bool> repeat = default);

finished Action<Double,Boolean>

An action to call when the animation is finished.

await Task.WhenAll(
    dialogControl.FadeTo(1, 1000), 
    dialogControl.ScaleTo(1, 1000)
);

Debug.WriteLine("Do some task after multiple animations are completed");