development-plugin-for-avalonia

Fluent Motion, Composition, and Depth Recipes in Avalonia

Table of Contents

  1. Scope and Primary APIs
  2. Fluent Motion Rules
  3. Fluent Transition Recipes
  4. Fluent Composition Recipe
  5. Depth, Materials, and Motion
  6. AOT and Runtime Notes
  7. Do and Don’t Guidance
  8. Troubleshooting
  9. Official Resources

Scope and Primary APIs

Use this reference to turn Fluent motion guidance into concrete Avalonia motion and composition patterns.

Primary APIs:

Fluent Motion Rules

Fluent motion should be:

Use motion to:

Use less motion when:

Fluent Transition Recipes

<Border xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Classes="fluent-command-card"
        Opacity="0.96"
        RenderTransform="translateY(0px)">
  <Border.Transitions>
    <Transitions>
      <TransformOperationsTransition Property="RenderTransform" Duration="0:0:0.16" />
      <DoubleTransition Property="Opacity" Duration="0:0:0.16" />
      <BoxShadowsTransition Property="BoxShadow" Duration="0:0:0.16" />
    </Transitions>
  </Border.Transitions>
</Border>
<CompositePageTransition xmlns="https://github.com/avaloniaui"
                         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                         x:Key="FluentShellTransition">
  <CompositePageTransition.PageTransitions>
    <CrossFade Duration="0:0:0.18" />
    <PageSlide Duration="0:0:0.18" Orientation="Horizontal" />
  </CompositePageTransition.PageTransitions>
</CompositePageTransition>

<TransitioningContentControl PageTransition="{StaticResource FluentShellTransition}"
                             Content="{CompiledBinding CurrentView}" />

Guidance:

Fluent Composition Recipe

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

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

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

var fade = compositor.CreateScalarKeyFrameAnimation();
fade.InsertKeyFrame(0f, 0.9f);
fade.InsertKeyFrame(1f, 1f);
fade.Duration = TimeSpan.FromMilliseconds(160);

visual.StartAnimation("Scale", scale);
visual.StartAnimation("Opacity", fade);

var center = compositor.CreateExpressionAnimation(
    "Vector3(this.Target.Size.X * 0.5, this.Target.Size.Y * 0.5, 1)");
visual.StartAnimation("CenterPoint", center);

Use composition for:

Depth, Materials, and Motion

Depth rules:

Practical guidance:

AOT and Runtime Notes

Do and Don’t Guidance

Do:

Do not:

Troubleshooting

  1. Fluent motion feels too loud.
    • Reduce translation distance, accent emphasis, and shadow depth together.
  2. Composition-driven shell polish looks disconnected.
    • Reuse the same duration and easing grammar as your XAML transitions.
  3. Elevated surfaces feel muddy in dark theme.
    • Lower transparency and motion strength before increasing shadow.

Official Resources