Skip to content
A powerful and easy to use library to work with Composition and XAML animations and Win2D effects
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


The UICompositionAnimations library exposes classes and APIs to quickly implement animations and effects to a UWP application. It also has a collection of helper methods to load Win2D images, dispatch code to the UI thread and more.

Get it from NuGet

NuGet NuGet

Used by

OneLocker myTube! Brainf*ck#
OneLocker screens IDE IDE

Table of Contents

Installing from NuGet

To install UICompositionAnimations, run the following command in the Package Manager Console

Install-Package UICompositionAnimations

More details available here.

Quick start


The available animation APIs use the fluent pattern and support combining multiple animations togetger. The main entry point is the UIElementExtensions.Animation method, that returns an IAnimationBuilder object targeting the input UIElement. This object exposes all the available animation APIs.

You can use it like this:

         .Translation(Axis.X, 60)

It is also possible to set an initial delay, and to wait for the animation to be completed. Also, should you need to do so in a particular situation, it is also possible to choose between the Windows.UI.Composition and Windows.UI.Xaml.Media.Animation APIs to run the animations. To toggle between the two, just pass a FrameworkLayer value to the Animation method. Furthermore, each animation API has two overloads: one that just takes the target value, and one that also sets the initial value for the animation. It is also possible to specify an easing function for each individual animation. Here is another, more complex example:

await MyControl.Animation(FrameworkLayer.Xaml)
               .Opacity(0, 1, Easing.CircleEaseOut)
               .Scale(1.2, 1, Easing.QuadraticEaseInOut)

UI.Composition effects

The library provides several ways to use UI.Composition effects: there are both ready to use XAML brushes (like a customizable acrylic brush), a CompositionBrushBuilder class to create complex composition effect pipelines, and more.

Declare an acrylic brush in XAML

<!--The acrylic brush to use in the app-->

Note: the NoiseTextureUri parameter must be set to a .png image with a noise texture. It is up to the developer to create his own noise texture and to import it into the app. An easy plugin to create one is NoiseChoice for Paint.NET.

Create custom effects in XAML:

Using the APIs in UICompositionAnimations.Brushes.Effects it is also possible to build complex Composition/Win2D pipelines directly from XAML, in a declarative way. This is how to define a custom host backdrop acrylic brush:


        <effects:BackdropEffect Source="HostBackdrop"/>
        <effects:OpacityEffect Value="0.4"/>
        <effects:BlendEffect Mode="Multiply">
                <effects:BackdropEffect Source="HostBackdrop"/>
        <effects:TintEffect Color="#FF1E90FF" Opacity="0.2"/>
        <effects:BlendEffect Mode="Overlay" Placement="Background">
                <effects:TileEffect Uri="/Assets/noise_high.png"/>

Create and assign an acrylic brush in C#

control.Background = PipelineBuilder.FromHostBackdropAcrylic(Colors.DarkOrange, 0.6f, new Uri("ms-appx:///Assets/noise.png"))

Build an acrylic effect pipeline from scratch:

Brush brush = PipelineBuilder.FromHostBackdropBrush()
                             .Effect(source => new LuminanceToAlphaEffect { Source = source })
                             .Blend(PipelineBuilder.FromHostBackdropBrush(), BlendEffectMode.Multiply)
                             .Tint(Color.FromArgb(0xFF, 0x14, 0x14, 0x14), 0.8f)
                             .Blend(PipelineBuilder.FromTiles("/Assets/noise.png".ToAppxUri()), BlendEffectMode.Overlay, Placement.Background)

The PipelineBuilder class can also be used to quickly implement custom XAML brushes with an arbitrary effects pipeline. To do so, just inherit from XamlCompositionEffectBrushBase and setup your own effects pipeline in the OnBrushRequested method.

Get a custom effect that can be animated:

// Build the effects pipeline
XamlCompositionBrush acrylic = PipelineBuilder.FromHostBackdropAcrylic(Colors.Orange, 0.6f, new Uri("ms-appx:///Assets/noise.png"))
                                              .Saturation(1, out EffectAnimation animation)
acrylic.Bind(animation, out XamlEffectAnimation saturation); // Bind the effect animation to the target brush

// Later on, when needed
saturation(0.2f, 250); // Animate the opacity to 0.2 in 250ms


Many utility methods are also available, here are some useful classes:

  • DispatcherHelper: exposes methods to easily execute code on the UI thread or on a target CoreDispatcher object
  • Win2DImageHelper: exposes APIs to quickly load a Win2D image on a CompositionSurfaceBrush object
  • PointerHelper: exposes APIs to quickly setup pointer event handlers for UIElements
  • AsyncMutex: an async mutex included into System.Threading.Tasks that can be used to asynchronously acquire a lock with a using block.


At least Windows 10 April Update (17134.x)

You can’t perform that action at this time.