Separate animations work, Storyboard doesn't. Why?

前端 未结 2 1555
无人共我
无人共我 2021-01-16 03:02

EDIT 1 : In order to satisfy "Complete, Minimal And Verifiable" Example Requirement

TL:DR; Storyboard doesn\'t animate at all. Why?

<
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-16 03:48

    For some reason, Storyboard.SetTarget only works with FrameworkElements or FrameworkContentElements. To do what you want, you can either start the individual animations yourself as you have in your "hack" (a perfectly reasonable way of doing animations, IMO).

    Or you can register names for all your targets, e.g.:

    foreach (var gs in gsc)
    {
        var name = "GS_" + Guid.NewGuid().ToString("N");
        RegisterName(name, gs);
        Storyboard.SetTargetName(caukf, name);
    }
    

    If you decide to invoke the animations directly, you really don't need to save them in a separate list. Just start them immediately in the first loop as soon as they are created.

    Storyboards are great if you need more coordination, such as pausing animations, using name scopes, advanced timing or animate from XAML. But in your case it seems simple Timelines would be adequate.

提交回复
热议问题