Learn Performing Animation in .NET MAUI: Part 2
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (168).NET Core  (29).NET MAUI  (154)Angular  (95)ASP.NET  (51)ASP.NET Core  (81)ASP.NET MVC  (89)Azure  (40)Blazor  (186)BoldSign  (11)DocIO  (24)Essential JS 2  (101)Essential Studio  (194)File Formats  (51)Flutter  (127)JavaScript  (214)Microsoft  (118)PDF  (77)Python  (1)React  (87)Streamlit  (1)Succinctly series  (130)Syncfusion  (761)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (46)Windows Forms  (59)WinUI  (64)WPF  (147)Xamarin  (160)XlsIO  (29)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (135)Chart  (93)Cloud  (14)Company  (445)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (61)Development  (536)Doc  (7)DockingManager  (1)eBook  (98)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (30)Extensions  (21)File Manager  (6)Gantt  (17)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (426)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (36)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (11)Scheduler  (48)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (29)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (110)UI  (294)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (26)Visual Studio Code  (17)Web  (492)What's new  (276)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)

Learn Performing Animation in .NET MAUI: Part 2

Welcome to the second part of our blog on animation in .NET MAUI! In Part 1, we covered the basics of animation and how to add simple animations to your .NET MAUI application. Now, it’s time to take it to the next level and explore custom animation in .NET MAUI.

Custom animation allows you to create more complex and tailored animations. This blog will teach you how to create custom animations in your .NET MAUI apps.

Custom animation in .NET MAUI

The .NET Multi-Platform App UI, or .NET MAUI, is a framework for building cross-platform applications using the .NET ecosystem. One of the powerful features of .NET MAUI is the ability to add animations to your app to enhance the user experience and make it more visually appealing.

The Animation class is the foundation for all .NET MAUI animations. The ViewExtensions class provides the extension methods for creating one or more animation objects. When creating an animation object, we should specify the number of parameters, including the beginning and end values for the animated property and a callback function to update the property’s value as the animation progresses.

In addition to animating a single property, the Animation class allows you to create and synchronize child animations. This will enable you to create more complex animations that involve multiple properties and elements within your app.

To run an animation created with the Animation class, we need to call the Commit method and specify the duration of the animation. You can also specify a callback function to control whether the animation should repeat, as well as other parameters, such as easing functions, to control the speed and smoothness of the animation.

Easily build cross-platform mobile and desktop apps with the flexible and feature-rich controls of the Syncfusion .NET MAUI platform.

Create a custom animation

We will create an animation for a Cody image that appears to be moving and blocked by a brick wall. Cody then thinks and jumps over the wall with a flip. After successfully flipping over the wall, Cody will celebrate a jump before moving away.

We can achieve this animation with several different animation objects. Each one is responsible for animating a specific aspect of the Cody image.

For example, the movingLeftAnimation object is responsible for animating Cody’s movement from left to right, while the rotateJumpAnimation object is responsible for animating Cody’s rotation as it jumps over the wall.

Then, we need to add the animation objects to a parentAnimation object, which controls the overall flow of the animation. The parentAnimation object specifies the start and end times for each animation object, allowing them to be sequenced together to create the desired animation.

Finally, the parentAnimation object is committed to the screen using the Commit method. This method specifies the length of the animation (in our case, it is 10,000 milliseconds) and a flag to indicate that the animation should repeat indefinitely.

Refer to the following code example to initialize the UI.

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    <Grid WidthRequest="700" Margin="10">
         <Image x:Name="imageView"
         <Image WidthRequest="50"

Refer to the following code to create a visually appealing animation of the Cody image that moves and jumps over a brick wall.

var parentAnimation = new Animation();
var movingLeftAnimation = new Animation(v => imageView.TranslationX = v, 0, 250);
var movingLeftBackAnimation = new Animation(v => imageView.TranslationX = v, 250, 200);
var movingRightAnimation = new Animation(v => imageView.TranslationX = v, 500, 700);
var rotateJumpAnimation = new Animation(v => imageView.Rotation = v, 0, 360);
var movingJumpAnimation = new Animation(v => imageView.TranslationX = v, 200, 500);
var movingJumpUpAnimation = new Animation(v => imageView.TranslationY = v, 0, -200);
var movingJumpDownAnimation = new Animation(v => imageView.TranslationY = v, -200, 0);
var jumpUpAnimation = new Animation(v => imageView.TranslationY = v, 0, -30);
var jumpDownAnimation = new Animation(v => imageView.TranslationY = v, -30, 0);
var jumpUpAnimation2 = new Animation(v => imageView.TranslationY = v, 0, -30);
var jumpDownAnimation2 = new Animation(v => imageView.TranslationY = v, -30, 0);
parentAnimation.Add(0, 0.15, movingLeftAnimation);
parentAnimation.Add(0.25, 0.35, movingLeftBackAnimation);
parentAnimation.Add(0.35, 0.65, rotateJumpAnimation);
parentAnimation.Add(0.35, 0.65, movingJumpAnimation);
parentAnimation.Add(0.35, 0.5, movingJumpUpAnimation);
parentAnimation.Add(0.5, 0.65, movingJumpDownAnimation);
parentAnimation.Add(0.7, 0.75, jumpUpAnimation);
parentAnimation.Add(0.75, 0.8, jumpDownAnimation);
parentAnimation.Add(0.8, 0.85, jumpUpAnimation2);
parentAnimation.Add(0.85, 0.9, jumpDownAnimation2);
parentAnimation.Add(0.9, 1, movingRightAnimation);
parentAnimation.Commit(this, "ChildAnimations", 16, 10000, null, null,repeat:()=>true);
Creating a Custom Animation in .NET MAUI
Creating a Custom Animation in .NET MAUI

Syncfusion .NET MAUI controls are well-documented, which helps to quickly get started and migrate your Xamarin apps.

Custom animation with ViewExtensions class

The ViewExtensions class in .NET MAUI allows us to animate a property from its current value to the specified value. However, this will be difficult when creating a color-changing animation method that animates a color property from one value to another, as different controls have different color properties.

To solve this problem, the PaintTo method can be written with a callback method that passes the interpolated color value back to the caller and takes the start and end color arguments.

Refer to the following code example.

public static class ViewExtensions
    public static Task<bool> PaintTo(this VisualElement element, Color startColor, Color endColor, Action<Color> callback, uint length = 250, Easing easing = null)
        Func<double, Color> transform = (t) =>
            Color.FromRgba(startColor.Red + t * (endColor.Red - startColor.Red),
                           startColor.Green + t * (endColor.Green - startColor.Green),
                           startColor.Blue + t * (endColor.Blue - startColor.Blue),
                           startColor.Alpha + t * (endColor.Alpha - startColor.Alpha));
        return ChangePaint(element, "ChangePaint", transform, callback, length, easing);
    public static void Cancel(this VisualElement self)
    static Task<bool> ChangePaint(VisualElement element, string animation, Func<double, Color> transform, Action<Color> callback, uint length, Easing effect)
        effect = effect ?? Easing.Linear;
        var source = new TaskCompletionSource<bool>();
        element.Animate<Color>(animation, transform, callback, 16, length, effect, (v, c) => source.SetResult(c));
        return source.Task;
Creating Color-Changing Custom Animation in .NET MAUI
Creating Color-Changing Custom Animation in .NET MAUI


For more details, refer to the custom animation in the .NET MAUI documentation.

To make it easy for developers to include Syncfusion .NET MAUI controls in their projects, we have shared some working ones.


Thanks for reading! In this blog, we have seen how to create custom animations in your .NET MAUI applications. With these animations, you can provide a wonderful user experience in your apps!

Syncfusion .NET MAUI controls were built from scratch using .NET MAUI, so they feel like framework controls. They are fine-tuned to work with a vast volume of data. Use them to build your cross-platform mobile and desktop apps!

The Essential Studio for .NET MAUI suite is available from the License and Downloads page. If you are not a Syncfusion customer, you can always download our free evaluation to see all our controls.

For questions, you can contact us through our support forum, support portal, or feedback portal. We are always happy to assist you!

Test Flight
App Center Badge
Google Play Store Badge
Microsoft Badge
Github Store Badge

Related blogs


Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed
Scroll To Top