development-plugin-for-avalonia

Fluent Advanced Composition, Implicit Animations, and Shell Choreography

Table of Contents

  1. Scope and Primary APIs
  2. Fluent Shell-Choreography Rules
  3. Implicit Animation Recipe
  4. Expression and Animation-Group Recipe
  5. AOT and Runtime Notes
  6. Do and Don’t Guidance
  7. Troubleshooting
  8. Official Resources

Scope and Primary APIs

Use this reference when Fluent shell polish needs deeper composition control than simple transitions.

Primary APIs:

Fluent Shell-Choreography Rules

Advanced Fluent motion should:

Use deeper composition choreography for:

Implicit Animation Recipe

using System;
using Avalonia.Rendering.Composition;

var visual = ElementComposition.GetElementVisual(ShellPane)!;
var compositor = visual.Compositor;

var offsetAnimation = compositor.CreateVector3KeyFrameAnimation();
offsetAnimation.Target = "Offset";
offsetAnimation.InsertExpressionKeyFrame(1f, "this.FinalValue");
offsetAnimation.Duration = TimeSpan.FromMilliseconds(180);

var implicitAnimations = compositor.CreateImplicitAnimationCollection();
implicitAnimations["Offset"] = offsetAnimation;

visual.ImplicitAnimations = implicitAnimations;

Use this for:

Expression and Animation-Group Recipe

using System;
using System.Numerics;
using Avalonia.Rendering.Composition;

var visual = ElementComposition.GetElementVisual(CommandSurface)!;
var compositor = visual.Compositor;

var scale = compositor.CreateVector3KeyFrameAnimation();
scale.Target = "Scale";
scale.InsertKeyFrame(0f, new Vector3(0.985f, 0.985f, 1f));
scale.InsertKeyFrame(1f, new Vector3(1f, 1f, 1f));
scale.Duration = TimeSpan.FromMilliseconds(160);

var slide = compositor.CreateVector3KeyFrameAnimation();
slide.Target = "Offset";
slide.InsertKeyFrame(0f, new Vector3(0f, 6f, 0f));
slide.InsertKeyFrame(1f, new Vector3(0f, 0f, 0f));
slide.Duration = TimeSpan.FromMilliseconds(160);

var group = compositor.CreateAnimationGroup();
group.Add(scale);
group.Add(slide);

visual.StartAnimationGroup(group);

var emphasis = compositor.CreateExpressionAnimation("baseOpacity * emphasis");
emphasis.Target = "Opacity";
emphasis.SetScalarParameter("baseOpacity", 1f);
emphasis.SetScalarParameter("emphasis", 0.98f);
visual.StartAnimation("Opacity", emphasis);

CompositionPropertySet exists in Avalonia 11.3.12, but app code typically drives shared composition input through animation parameters because there is no public compositor factory for constructing property sets directly.

AOT and Runtime Notes

Do and Don’t Guidance

Do:

Do not:

Troubleshooting

  1. Shell polish feels too busy.
    • Reduce the number of simultaneously animated properties and simplify the hierarchy story.
  2. Advanced composition looks disconnected from normal transitions.
    • Reuse the same timing and easing grammar between XAML and composition paths.
  3. Elevated surfaces still feel muddy.
    • Reduce transparency and color emphasis before increasing motion.

Official Resources