Telerik blogs

Bring a little extra holiday cheer to your .NET MAUI app with one of these five simple Christmas animations.

I absolutely love animations that bring apps to life! 😍 There’s something about movement and those little interactive details that make an app feel more welcoming, fun and enjoyable to explore.

Now, imagine bringing that same magic into a special theme like Christmas! 🎅

In this article, we’re going to create five Christmas animations using .NET MAUI’s native animations. From twinkling Christmas lights to falling snowflakes, we’ll discover how just a few lines of code can make our apps feel magical!

So, grab your favorite cup of coffee ☕, get comfortable and let’s get started! 🎄💖

1. Jingle Bell Animation 🔔

Let’s start by animating a Christmas bell to recreate its natural side-to-side swinging motion. You won’t believe how easy it is to create this animation in .NET MAUI! All you need is an image of a bell and the RotateTo() method.

Let’s see how it works in the following example!

XAML:

<Image 
    x:Name="BellImage" 
    Source="jinglebell" 
    WidthRequest="200" 
    HeightRequest="200" 
    AnchorX="0.5" 
    AnchorY="0.1" 
    HorizontalOptions="Center" 
    VerticalOptions="Center" />

C#:

protected override async void OnAppearing() 
{ 
    base.OnAppearing();  
    await BellImage.RotateTo(12, 450, Easing.SinInOut); 
    
    while (true) 
	    { 
		    await BellImage.RotateTo(-12, 900, Easing.SinInOut); 
		    await BellImage.RotateTo(12, 900, Easing.SinInOut); 
	    } 
}

2. Christmas Tree Lights Animation 🎄✨

What’s a Christmas tree without twinkling lights? ✨

Let’s bring our Christmas tree to life by dynamically adding colorful lights to a simple tree vector! We’ll use the FadeTo() method to make the lights blink on and off, creating a beautiful twinkling effect.

Let’s see how easy it is to create this animation in .NET MAUI!

XAML:

<Grid 
    x:Name="TreeContainer" 
    VerticalOptions="Start" 
    WidthRequest="240" 
    HeightRequest="300">
 
    <Image 
    Source="christmastreenolights" 
    Aspect="Fill" /> 
</Grid>

C#:

private readonly List<Ellipse> _lights = [];
 
protected override async void OnAppearing() 
{ 
base.OnAppearing();
 
if (_lights.Count == 0) 
{ 
var positions = new (double X, double Y)[] 
    { 
	    (0, -73), 
	    (-27, -39), (24, -18), 
	    (-48, 19), (3, 29), (47, 49), 
	    (-63, 89), (-13, 79), (33, 94) 
	    }; 

    string[] colors = ["#FFD86B", "#F36C79", "#74D5FF"];
     
    for (int i = 0; i < positions.Length; i++) 
    { 
	    var light = new Ellipse  
	    { 
	    Fill = new SolidColorBrush( 
	    Color.FromArgb(colors[i % colors.Length])), 
	    WidthRequest = 12, 
	    HeightRequest = 12, 
	    HorizontalOptions = LayoutOptions.Center, 
	    VerticalOptions = LayoutOptions.Center, 
	    TranslationX = positions[i].X, 
	    TranslationY = positions[i].Y 
    };
     
    TreeContainer.Children.Add(light); 
    _lights.Add(light); 
    } 
}
 
    while (true) 
    { 
	    foreach (var light in _lights) 
	    { 
		    await light.FadeTo(0.2, 180); 
		    await light.FadeTo(1, 180); 
	    } 
    } 
}

3. Christmas Gift-Opening Animation 🎁✨

OMG! I can’t decide which animation is my favorite, but I think this one might be one of them! 😍

This time, we’ll create a magical animation where a Christmas gift box opens and a beautiful, warm glow shines from inside! We’ll combine three .NET MAUI animation methods: FadeTo(), ScaleTo() and TranslateTo() to bring our gift to life.

Let’s see how it works! ✨

XAML:

<Grid 
    WidthRequest="240" 
    HeightRequest="240" 
    HorizontalOptions="Center" 
    VerticalOptions="Start”>
 
    <!-- Warm glow --> 
    <Ellipse 
	    x:Name="GiftGlow" 
	    WidthRequest="200" 
	    HeightRequest="200" 
	    TranslationY="-35" 
	    Opacity="0" 
	    Scale="0.3">
     
	    <Ellipse.Fill> 
		    <RadialGradientBrush> 
			    <GradientStop Color="#FFFFF2B3" Offset="0" /> 
			    <GradientStop Color="#FFFFD76A" Offset="0.25" /> 
			    <GradientStop Color="#66FFB830" Offset="0.6" /> 
			    <GradientStop Color="#00FFB830" Offset="1" /> 
		    </RadialGradientBrush> 
	    </Ellipse.Fill> 
    </Ellipse>
     
    <!-- Gift box --> 
    <Image 
	    Source="giftbox.png" 
	    WidthRequest="130" 
	    HeightRequest="100" 
	    TranslationY="40" />
     
    <!-- Gift lid --> 
    <Image 
	    x:Name="GiftLid" 
	    Source="giftlid.png" 
	    WidthRequest="150" 
	    HeightRequest="28" 
	    TranslationY="-24" /> 
</Grid>

C#:

protected override async void OnAppearing() 
{ 
    base.OnAppearing();
     
    while (true) 
    { 
	    // Open the gift 
	    await Task.WhenAll( 
	    GiftLid.TranslateTo(0, -85, 650, Easing.SinOut), 
	    GiftGlow.FadeTo(1, 650), 
	    GiftGlow.ScaleTo(1.2, 650) 
	    );
	     
	    // Magical glow pulse 
	    await GiftGlow.ScaleTo(1.5, 800, Easing.SinInOut); 
	    await GiftGlow.ScaleTo(1.2, 800, Easing.SinInOut);
	     
	    
	    // Close the gift 
	    await Task.WhenAll( 
	    GiftLid.TranslateTo(0, -24, 650, Easing.SinInOut),  
	    GiftGlow.FadeTo(0, 650), 
	    GiftGlow.ScaleTo(0.3, 650) 
	    );
	     
	    await Task.Delay(500); 
    } 
}

4. Falling Snowflakes Animation ❄️

Let’s create a beautiful snowfall animation with snowflakes falling gently across the screen! We’ll use different sizes, speeds and positions to make the snowfall look more natural and magical. Let’s see how easy it is to bring this winter to life in .NET MAUI!

XAML:

<Grid 
x:Name="SnowContainer" 
BackgroundColor="#142B49" />

C#:

protected override async void OnAppearing() 
{ 
base.OnAppearing();
 
await Task.Delay(300);
 
for (int i = 0; i < 25; i++) 
    { 
	    var size = Random.Shared.Next(12, 28); 
	    var snowflake = new Image 
	    { 
		    Source = "snowflake.png", 
		    WidthRequest = size, 
		    HeightRequest = size, 
		    Opacity = Random.Shared.Next(5, 10) / 10.0, 
		    HorizontalOptions = LayoutOptions.Start, 
		    VerticalOptions = LayoutOptions.Start 
	    };
 
SnowContainer.Children.Add(snowflake); 
_ = FallAsync(snowflake); 
await Task.Delay(180); 
} 
}

private async Task FallAsync(Image snowflake) 
{ 
    while (true) 
    { 
	    var x = Random.Shared.NextDouble() * 
	    Math.Max(0, SnowContainer.Width - 50);
	     
	    snowflake.TranslationX = x; 
	    snowflake.TranslationY = -30;
	     
	    await snowflake.TranslateTo( 
	    x + Random.Shared.Next(-40, 41), 
	    SnowContainer.Height + 30,  
	    (uint)Random.Shared.Next(5000, 10000), 
	    Easing.Linear); 
    } 
}

5. Santa’s Hat Animation 🎅🎄

Let’s wrap up our Christmas animations with a little Santa magic! ✨

In this final animation, we’ll make Santa’s hat gently bounce up and down while its fluffy pom-pom swings from side to side. To bring it to life, we’ll combine TranslateTo() and RotateTo() to create a fun, playful effect with just a few lines of code.

XAML:

<Grid 
    x:Name="SantaHat" 
    WidthRequest="220" 
    HeightRequest="200" 
    HorizontalOptions="Center" 
    VerticalOptions="Start"> 
    
    <Image 
	    Source="santahat.png" 
	    WidthRequest="220" 
	    HeightRequest="200" />
 
    <Image 
	    x:Name="PomPom" 
	    Source="santapom.png" 
	    WidthRequest="44" 
	    HeightRequest="44" 
	    HorizontalOptions="Center" 
	    VerticalOptions="Center" 
	    TranslationX="84" 
	    TranslationY="16" 
	    AnchorX="0.1" 
	    AnchorY="0.2" /> 
</Grid>

C#:

protected override async void OnAppearing() 
{ 
base.OnAppearing();
  
    while (true) 
    { 
	    await Task.WhenAll( 
	    SantaHat.TranslateTo(0, -15, 500, Easing.SinInOut), 
	    PomPom.RotateTo(20, 500, Easing.SinInOut) 
	    );
     
	    await Task.WhenAll( 
	    SantaHat.TranslateTo(0, 0, 500, Easing.SinInOut), 
	    PomPom.RotateTo(-20, 500, Easing.SinInOut) 
	    ); 
    } 
}

Conclusion

And that’s it! 🎉 See how we created such beautiful animations in just a few minutes?

The key is to think outside the box and remember that with the native animations available in .NET MAUI, we can create amazing things with just a few lines of code!

From making Christmas tree lights blink, to watching snowflakes fall across our screens, and even bringing Santa’s hat to life, we’ve seen how simple animations can add a little Christmas magic to our apps! 🎅❄️

Now it’s your turn! I encourage you to explore, experiment and let your creativity shine. Don’t limit yourself to Christmas animations. Imagine all the fun things you can create! 🚀

See you in the next article! 💖


LeomarisReyes
About the Author

Leomaris Reyes

Leomaris Reyes is a software engineer from the Dominican Republic specializing in mobile development. She is a 7-time Microsoft MVP and actively builds mobile applications while sharing practical knowledge through technical articles and developer-focused content.

Through her work, she explains programming concepts, developer tools and real-world development practices to help developers grow in their careers.

You can follow her on Instagram and TikTok at @leomarisreyes.dev, read her articles on AskXammy, and connect with her on LinkedIn, where she shares tutorials, insights and resources for developers.

Related Posts

Comments

Comments are disabled in preview mode.