• Stars
    star
    460
  • Rank 95,202 (Top 2 %)
  • Language
    C#
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Xamarin Forms Animation Library

Xamanimation - Animation Library for Xamarin.Forms

Xamanimation is a library designed for Xamarin.Forms that aims to facilitate the use of animations to developers. Very simple use from C# and XAML code.

Xamanimation

We can define animations in XAML to a visual element when loading through a Behavior, use a trigger in XAML to execute the animation or from C# code.

Available animations:

  • Color
  • FadeTo
  • Flip
  • Heart
  • Jump
  • Rotate
  • Scale
  • Shake
  • Translate
  • Turnstile

Installation

To install Xamanimation, run the following command in the Package Manager Console.

PM> Install-Package Xamanimation

Animations directly from XAML

One of the main advantages of the library is the possibility of using animations from XAML. We must use the following namespace:

xmlns:xamanimation="clr-namespace:Xamanimation;assembly=Xamanimation"

Let's animate a BoxView:

<BoxView
     x:Name="FadeBox"
     HeightRequest="120"
     WidthRequest="120"
     Color="Blue" />

we can define animations directly in XAML (as Application or Page Resources):

<xamanimation:FadeToAnimation
     x:Key="FadeToAnimation"
     Target="{x:Reference FadeBox}"
     Duration="2000"
     Opacity="0"/>

Using the namespace of xamanimation, we have access to the whole set of animations of the library. In all of them there are a number of common parameters such as:

  • Target: Indicate the visual element to which we will apply the animation.
  • Duration: Duration of the animation in milliseconds.

Depending on the animation type used, we will have more parameters to customize the specific animation. For example, in the case of Fade Animation we will have an Opacity property to set how we modify the opacity.

To launch the animation we have two options:

  • Trigger: Called BeginAnimation that allows us to launch an animation when a condition occurs.
  • Behavior: We have a Behavior called BeginAnimation that we can associate to a visual element so that indicating the desired animation, we can launch the same when the element load occurs.

Using the Clicked event of a button we can launch the previous animation using the trigger provided:

<Button 
     Text="Fade">
     <Button.Triggers>
          <EventTrigger Event="Clicked">
               <xamanimation:BeginAnimation
                    Animation="{StaticResource FadeToAnimation}" />
          </EventTrigger>
     </Button.Triggers>
</Button>

We also have the concept of Storyboard as a set of animations that we can execute over time:

<xamanimation:StoryBoard
     x:Key="StoryBoard"
     Target="{x:Reference StoryBoardBox}">
     <xamanimation:ScaleToAnimation  Scale="2"/>
     <xamanimation:ShakeAnimation />
</xamanimation:StoryBoard>

Using C#

In the same way that we can use the animations of the library from XAML, we can do it from C# code. We have an extension method called Animate that expects an instance of any of the available animations.

If we want to animate a BoxView called AnimationBox:

<BoxView
     x:Name="AnimationBox"
     HeightRequest="120"
     WidthRequest="120"
     Color="Blue" />

Access the element, use the Animate method with the desired animation:

AnimationBox.Animate(new HeartAnimation());

Take control of the animation

You can control the duration of the animation using the Duration property. In addition to the type of Easing to use. Now, new properties have also been added such as:

Delay Add a delay before play the animation.

Repeat Forever Now you can create infinite animations if you need it.

Triggers!

Triggers allow you to start animations declaratively in XAML based on events or property changes.

<Entry 
    FontSize="16" 
    BackgroundColor="LightGray">
    <Entry.Triggers>
        <Trigger TargetType="Entry" Property="IsFocused" Value="True">
            <Trigger.EnterActions>
                <xamanimation:AnimateDouble TargetProperty="Entry.FontSize" To="24"/>
                <xamanimation:AnimateColor TargetProperty="Entry.TextColor" To="Red"/>
                <xamanimation:AnimateColor TargetProperty="VisualElement.BackgroundColor" To="Yellow" Delay="1000"/>
                <xamanimation:AnimateDouble TargetProperty="VisualElement.Rotation" To="12" Duration="100"/>
            </Trigger.EnterActions>
            <Trigger.ExitActions>
                <xamanimation:AnimateDouble TargetProperty="{x:Static Entry.FontSizeProperty}" To="16"/>
                <xamanimation:AnimateColor TargetProperty="{x:Static Entry.TextColorProperty}" To="Black"/>
                <xamanimation:AnimateColor TargetProperty="{x:Static VisualElement.BackgroundColorProperty}" To="LightGray"/>
                <xamanimation:AnimateDouble TargetProperty="{x:Static VisualElement.RotationProperty}" To="0"/>
            </Trigger.ExitActions>
        </Trigger>
    </Entry.Triggers>
</Entry>

You can animate any property of type Int, Double, Color, Thickness or CornerRadius. Available options:

  • AnimateInt
  • AnimateColor
  • AnimateCornerRadius
  • AnimateDouble
  • AnimateThickness

Progress Animations

Sometimes you need to animate something based on a value that changes over time, for example as a a the result of a user interaction.

A common scenario is using a scroll. A parallax effect, etc.

<BoxView 
    BackgroundColor="Red"
    CornerRadius="24, 24, 0, 0">
    <VisualElement.Behaviors>
        <xamanimation:AnimateProgressColor
            TargetProperty="VisualElement.BackgroundColor"
            Progress="{Binding ScrollY, Source={x:Reference ScrollBehavior}}" 
            Minimum="0"
            Maximum="200"
            From="Black"
            To="Red"/>
        <xamanimation:AnimateProgressCornerRadius
            TargetProperty="BoxView.CornerRadius"
            Progress="{Binding ScrollY, Source={x:Reference ScrollBehavior}}" 
            Minimum="0"
            Maximum="200"
            From="24, 24, 0, 0"
            To="0,0,0,0"/>
    </VisualElement.Behaviors>
</BoxView>

Available options:

  • AnimateProgressInt
  • AnimateProgressColor
  • AnimateProgressCornerRadius
  • AnimateProgressDouble
  • AnimateProgressThickness

Transitions

Provides the animated transition behavior on controls when they first appear. You can use this on individual objects or on containers of objects. In the latter case, child elements will animate into view in sequence rather than all at the same time.

<FlexLayout 
     Wrap="Wrap"
	 Direction="Row"
	 JustifyContent="Start"
	 AlignItems="Start"
	 AlignContent="Start">
	 <FlexLayout.Behaviors>
	 <xamanimation:EntranceTransition
	      Duration="1000"/>
	 </FlexLayout.Behaviors>
</FlexLayout>

Feedback

Please use GitHub issues for questions or comments.

Copyright and license

Code released under the MIT license.

More Repositories

1

xamarin-forms-goodlooking-UI

Xamarin.Forms goodlooking UI samples
2,540
star
2

awesome-dotnet-maui

A curated list of awesome .NET MAUI libraries and resources.
1,773
star
3

awesome-xamarin-forms

A curated list of awesome Xamarin.Forms libraries and resources
C#
1,246
star
4

dotnet-maui-showcase

A curated list of awesome .NET MAUI samples
849
star
5

TemplateUI

A set of Xamarin.Forms templated controls.
C#
422
star
6

AlohaKit.Controls

A set of .NET MAUI drawn controls.
C#
389
star
7

figma-to-maui-graphics

FigmaSharp.Maui.Graphics turns your Figma design into .NET MAUI Graphics code
C#
330
star
8

AlohaKit.Animations

AlohaKit.Animations is a library designed for .NET MAUI that aims to facilitate the use of animations to developers.
C#
214
star
9

netmaui-chat-app-challenge

Chat App UI Challenge made with .NET MAUI.
C#
214
star
10

xamarin-forms-page-transitions

Custom page transitions in a Xamarin.Forms App
C#
211
star
11

xamarin-forms-netflix-sample

A Xamarin.Forms version of the Netflix app to prove you can create goodlooking UI with Xamarin.Forms.
C#
194
star
12

forms-gtk-progress

Xamarin.Forms GTK Backend Progress
191
star
13

xamarin-forms-perf-playground

Xamarin.Forms Performance Playground (Layouts, Bindings, XAMLC, etc)
C#
128
star
14

AlohaKit.Layouts

.NET MAUI Layouts Library
C#
120
star
15

Art-Plant-Mall

Xamarin.Forms goodlooking UI sample.
C#
111
star
16

MyTripCountdown

Xamarin.Forms goodlooking UI sample
C#
108
star
17

xamarin-forms-to-net-maui

This repository is a compilation with documentation, examples and tips when converting code from Xamarin.Forms to .NET MAUI.
C#
104
star
18

AlohaKit.UI

This library offers an easier way to create drawn controls in .NET MAUI in both XAML and C#.
C#
101
star
19

PulseMusic

Xamarin.Forms goodlooking UI sample
C#
88
star
20

ways-create-netmaui-controls

In this repository we collect all the ways to create or extend controls in .NET MAUI.
C#
86
star
21

xamarin-forms-gtk-movies-sample

The Movie DB Xamarin.Forms Sample
C#
83
star
22

MyTasks

Xamarin.Forms goodlooking UI sample.
C#
75
star
23

xamarin-forms-gui.cs

Xamarin.Forms gui.cs Backend
C#
74
star
24

dotnet-maui-samples

The samples in this repository demonstrate how to use different aspects of .NET MAUI to build cross-platform apps for iOS, Android, macOS and the Windows.
C#
67
star
25

netmaui-carrental-app-challenge

CarRental App UI Challenge made with .NET MAUI.
C#
61
star
26

netmaui-movies-app-challenge

Movies App UI Challenge made with .NET MAUI.
C#
59
star
27

Xamarin.Forms.TabView

The TabView is a Xamarin.Forms control to display a set of tabs and their respective content.
C#
54
star
28

TravellingApp

Xamarin.Forms goodlooking UI sample using the new CarouselView.
C#
54
star
29

DrinksGalleryApp

Xamarin.Forms goodlooking UI sample using the new CarouselView (Parallax).
C#
53
star
30

netmaui-beautyshop-app-challenge

Beautyshop App UI Challenge made with .NET MAUI.
C#
53
star
31

Xamarin.Forms-Samples

Xamarin.Forms Samples!
C#
51
star
32

FocusOnXamarin

NET Conf: Focus on Xamarin samples
C#
49
star
33

xamarin-forms-walkthrough

Mobile App Walkthrough created with Xamarin.Forms
C#
47
star
34

FoodDeliveryAppDuo

Xamarin.Forms good looking UI sample for Surface Duo.
C#
41
star
35

netmaui-surfing-app-challenge

Surfing App UI Challenge made with .NET MAUI.
C#
41
star
36

openaisharp-maui

C# .NET wrapper library to use with OpenAI APIs.
C#
40
star
37

ArtNews

Xamarin.Forms goodlooking UI sample.
C#
38
star
38

TemplateMAUI

A set of .NET MAUI templated controls.
C#
38
star
39

netmaui-skateboard-ecommerce-app-challenge

Skateboard E-commerce App UI Challenge made with .NET MAUI.
C#
36
star
40

ShoppingList

Xamarin.Forms goodlooking UI sample using the new Expander Control.
C#
34
star
41

UAP-Samples

Windows 10 Universal App Platform
C#
34
star
42

netmaui-finance-app-challenge

Finance App UI Challenge made with .NET MAUI.
C#
34
star
43

TimelinePulse

Xamarin.Forms good looking UI sample.
C#
33
star
44

netmauigraphics-chat-app-challenge

Chat App UI Challenge made with .NET MAUI Graphics.
C#
33
star
45

FavFighters

Xamarin.Forms goodlooking UI sample using the new SwipeView.
C#
33
star
46

rive-maui

.NET MAUI runtime for Rive
C#
33
star
47

AvaloniaMauiHybrid.Controls

Easily expose Avalonia drawn controls to use in .NET MAUI.
C#
32
star
48

Events

Events Presentations and Samples
C#
31
star
49

netmaui-travel-app-challenge

Travel App UI Challenge made with .NET MAUI (and Xamarin.Forms).
C#
31
star
50

AlohaKit.Components

Cupertino, Fluent and Material drawn Controls with high performance and 100% customizable.
C#
31
star
51

Xampane

Xamarin Forms Layouts Library
C#
30
star
52

screenshot-to-maui

Convert a screenshot to .NET MAUI XAML code
C#
29
star
53

xamarin-forms-goodlooking-apps

Xamarin.Forms goodlooking UI apps
28
star
54

BindableLayoutPlayground

Xamarin.Forms BindableLayout Playground.
C#
28
star
55

taller-dotnet-maui

Taller de desarrollo de aplicaciones con .NET MAUI
27
star
56

awesome-monodevelop

A curated list of awesome Visual Studio for macOS and MonoDevelop addins, tools and resources.
25
star
57

MyTaxiCompany

Xamarin.Forms Map Application Sample
C#
24
star
58

FlightBookingApp

Xamarin.Forms goodlooking UI sample using the new SwipeView.
C#
24
star
59

netmaui-coupons-app-challenge

Coupons App UI Challenge made with .NET MAUI.
C#
21
star
60

Xamarin.Forms-Gallery

Xamarin.Forms Core Gallery redesign.
C#
20
star
61

netmaui-moon-nft-app-challenge

Moon NFT App UI Challenge made with .NET MAUI.
C#
18
star
62

FormsWPFConverter

Live XAML converter from WPF to Xamarin.Forms Tool
C#
17
star
63

netmaui-mytasks-app-challenge

Tasks App UI Challenge made with .NET MAUI.
C#
17
star
64

FormsGtkToolkit

The Forms Gtk Toolkit is a collection of Controls for Xamarin.Forms GTK Backend.
C#
17
star
65

xamarin-forms-statusbar

Xamarin.Forms Effect to manage the StatusBar BackgroundColor.
C#
16
star
66

XamarinFormsStateTriggers

A collection of custom visual state triggers for Xamarin.Forms
C#
16
star
67

FormsWPFLive

Live XAML development for Xamarin Forms Apps using WPF Backend.
C#
16
star
68

xamarin-forms-entityframework-sample

Xamarin.Forms App using Entity Framework Core 2.0
C#
16
star
69

VS4Mac-SkiaSharpFiddle

SkiaSharp playground VS4Mac addin.
C#
16
star
70

comet-travel-app-challenge

Travel App UI Challenge made with Comet.
C#
14
star
71

Xamarin.Forms.AppBar

An app bar consists of a Xamarin.Forms toolbar.
C#
14
star
72

xamarin-forms-wpf-weather-sample

Xamarin.Forms WPF Backend Weather Sample
C#
14
star
73

xamarin-forms-wpf-samples

Xamarin.Forms WPF Samples
C#
14
star
74

FormsGtkLive

Xamarin Forms GTK Backend Live Preview
C#
14
star
75

netmaui-teenfeel-app-challenge

TeenFeel App UI Challenge made with .NET MAUI.
C#
13
star
76

AvaloniaSkiaSharpFiddle

Avalonia SkiaSharp Fiddle is a SkiaSharp playground created with Avalonia and running on macOS, Linux, Windows and WebAssembly.
C#
13
star
77

DotNet2020

Ways to create controls in Xamarin.Forms
C#
13
star
78

xamarin-forms-gtk-samples

Xamarin.Forms GTK Samples
C#
13
star
79

mvpsummit2022-dotnet-maui

MVP Summit 2022 - .NET MAUI samples
C#
13
star
80

VS4Mac-LottiePlayer

VS4Mac addin to Preview Lottie json files.
C#
12
star
81

xamarin-forms-channel9-sample

Channel 9 Application made with Xamarin.Forms.
C#
12
star
82

xamarin-forms-arcore-sample

Xamarin.Forms ARCore Sample using Wave Engine
C#
12
star
83

dotnet-maui-course-resources

.NET MAUI course
C#
12
star
84

ShapesPlayground

Sample to show how to use Shapes in Xamarin.Forms
C#
11
star
85

alohakit-blazor-prototype

Prototype and test to bring drawn controls from .NET MAUI to Blazor WebAssembly.
HTML
11
star
86

monkeyconf-website

Website project of the Monkey Conf event created using Xamarin.Forms.
C#
11
star
87

RelativeSourcePlayground

Xamarin.Forms RelativeSource sample
C#
10
star
88

flutter-chat-app-challenge

Chat App UI Challenge made with Flutter.
Dart
10
star
89

xamarin-forms-waveengine-sample

Xamarin.Forms Sample using Wave Engine
C#
10
star
90

chatgpt-maui-playground

In this repository there are ChatGPT tests generating code for specific .NET MAUI UI or creating small applications directly.
C#
9
star
91

MonkeyConf2018

Slides and samples from Monkey Conf 2018 event
C#
9
star
92

VS4Mac-AssetStudio

VS4Mac addin with functionality related to assets management.
C#
9
star
93

mvxforms-samples

Xamarin Forms MvvmCross Samples
C#
9
star
94

xamarin-forms-waveengine-ar-sample

Xamarin.Forms Augmented Reality Sample
C#
9
star
95

mauifest2022

MauiFest 2022 es un evento de comunidad online y gratuito para celebrar el lanzamiento de .NET MAUI
9
star
96

OxyPlot-Xamarin.Forms-Sample

OxyPlot Xamarin.Forms Sample
C#
9
star
97

xamarin-forms-ooui-movies-sample

The Movie DB Ooui Xamarin.Forms Sample
C#
8
star
98

AuroraControlsPlayground

Xamarin.Forms sample to show the main Aurora Controls features.
C#
8
star
99

xamarin-forms-gtk-iot-samples

Xamarin.Forms GTK Backend IoT Sample
C#
8
star
100

DotNetAlliance

La DotNet Alliance es una página web que agrupa todos los eventos de las comunidades .NET de España y los muestra en un calendario común.
8
star