In this tutorial series, we will see how to use animations in .NET Multi-platform App UI (.NET MAUI), this animation classes targ...

.Net MAUI - Animations .Net MAUI - Animations

.Net MAUI - Animations

.Net MAUI - Animations

In this tutorial series, we will see how to use animations in .NET Multi-platform App UI (.NET MAUI), this animation classes target different properties of visual elements, with a typical introductory animation progressively changing a property from one value to another over a period of time.


Quick Links:


Project Setup:

  • Launch Visual Studio 2022, and in the start window click Create a new project to create a new project.
  • In the Create a new project window, select MAUI in the All project types drop-down, select the .NET MAUI App template, and click the Next button:
  • In the configure your new project window, name your project, choose a suitable location for it, and click the Next button:
  • In the Additional information window, click the Create button:
  • Once the project is created, we can able to see the Android, iOS, Windows and other running options in the toolbar. Press the emulator or run button to build and run the app

Implementation:

  • Basic animations can be created with extension methods provided by the ViewExtensions class, in the Microsoft.Maui.Controls namespace, which operate on VisualElement objects.
  • In Solution Explorer, click on MainPage.xaml. Add Title="Main Page" to ContentPage and replace the content of the page to what is shown below:
  • Open MainPage.xaml.cs file and the content of the page to what is shown below:
  • .NET Multi-platform App UI (.NET MAUI) includes an Easing class that enables you to specify a transfer function that controls how animations speed up or slow down as they're running.
  • The animation extension methods in the ViewExtensions class allow an easing function to be specified as the final method argument:
  • To know more about animations, please visit https://learn.microsoft.com/en-us/dotnet/maui/user-interface/animation/easing

Demo:

Full Code:

Download Code:

You can download the code from GitHub. If you have any doubts, feel free to post a comment. If you liked this article, and it is useful to you, do like, share the article & star the repository on GitHub.

0 comments:

Please Comment about the Posts and Blog