Advertisement
Advanced .NET MAUI, Gestures & Animations

How do you create custom animations with the Animation class?

Short answer

Use the low-level Animation class to define a callback that receives a 0..1 value and applies it to any property, add child animations at offsets for choreography, then call Commit with duration, easing, repeat, and finished callbacks.

Save .NET MAUI mock interview
Advertisement
AModel answer
Use the low-level Animation class to define a callback that receives a 0..1 value and applies it to any property, add child animations at offsets for choreography, then call Commit with duration, easing, repeat, and finished callbacks. This enables animations beyond the built-in extension methods.
var anim = new Animation(v => box.Rotation = v, 0, 360);
anim.Commit(box, "spin", length: 1000,
    easing: Easing.Linear, repeat: () => true);
Real-world example
A loading indicator spins continuously via a custom Animation committed with repeat, without a third-party control.
Likely follow-ups
  • How do you choreograph child animations? | How do you make it repeat?
Related topics