Can I animate multiple properties simultaneously in .NET MAUI?

Platform: .NET MAUI| Category: General

Yes, you can animate multiple properties simultaneously using the Task.WhenAll method. For example, you can animate opacity and scale at the same time:

XAML

<Label x:Name="animatedLabel" Text="Hello, .NET MAUI!" Opacity="0" />
<Button Text="Animate" Clicked="OnAnimateClicked" WidthRequest="200" />

C#

async void OnAnimateClicked(object sender, EventArgs e)
 {
     //whenever the button is clicked
     await MultiplePropertyAnimation(animatedLabel);
 }       
 async Task MultiplePropertyAnimation(View view)
 {
     var opacityTask = view.FadeTo(1, 1000);
     var scaleTask = view.ScaleTo(1.2, 1000);
     await Task.WhenAll(opacityTask, scaleTask);
 }

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.