Awesome
<h1># Xamarin.forms.PropertyAnimation</h1> <p>This is an animation library for xamarin forms controls. We can animate any property with supported type. Currenlty this library has three types which can be animated.These are double, Integer and color. So if any control has any property with these types, we can animate that.</p> <p>We can download Nuget package for this library from https://www.nuget.org/packages/Xamarin.Forms.PropertyAnimation.</p> <p>This library has two type of animations.</p> <p><strong>1- Sequentional.</strong></p> <p><strong>2- Parallel.</strong></p> <p>In sequential property animation, each animation will start after completion of its previous animation but if we want to animate multiple properties simultaneously, We can use parellel property animation. Parallel property animation provides more feature including features of Sequentional property animation.</p> <p>This animator has few basic properties which need to understand.</p> <ol> <li><strong>StartValue</strong> : Initial value from where animation need to start:</li> <li><strong>EndValue</strong>: Last value where animation will finish.</li> <li><strong>PropertyName</strong>: Name of property which we want to animate.</li> <li><strong>Target</strong>: Which control's property need to animate.<br /><br />Except these properties there are few optional properties which also can be used to customize animation behaviour.<br /><br /></li> <li><strong>Toggle</strong>: This property instructs animator to reverse animation from EndValue to StartValue.</li> <li><strong>Duration</strong>: How long animation should run.</li> <li><strong>AnimationEasing</strong>: Animation Easing.</li> <li><strong>Rate</strong>: Frame rate of animation.</li> <li><strong>Delay</strong>: Not yet Implemented.</li> </ol> <h2><br /><strong>Usage:</strong></h2> <p><br /> Install Nuget package Xamarin.Forms.PropertyAnimation in shared project. <br /> <br /> Add Reference in xaml file or C# file.<br /> <br /> Xaml Example:<br /> <br /> <strong>xmlns:PA="clr-namespace:Animation;assembly=Animation"</strong><br /> <br /> C# Example<br /> <br /> <strong>using Animation;</strong><br /> <br /> After importing animation namespace, we can use animation library as following:<br /> <br /> <strong>Xaml:</strong></p> <p><strong>PropertyAnimation:</strong></p> <p><Button Text="Property Animation" BackgroundColor="#ffff0000" x:Name="btn" ><br /> <Button.Triggers><br /> <EventTrigger Event="Clicked" ><br /> <PA:PropertyAnimator Toggle="True"><br /> <PA:PropertyAnimator.PropertyAnimations ><br /> <PA:ColorAnimation StartValue="#ffff0000" EndValue="#ffffff00" PropertyName="BackgroundColor" Target="{x:Reference btn}" Length="500"></PA:ColorAnimation><br /> <PA:ColorAnimation StartValue="#00000000" EndValue="#ffffffff" PropertyName="TextColor" Target="{x:Reference btn}" Length="500" ></PA:ColorAnimation><br /> </PA:PropertyAnimator.PropertyAnimations><br /> </PA:PropertyAnimator><br /> </EventTrigger><br /> </Button.Triggers><br /> </Button></p> <p> </p> <p><strong>Parellel Property Animation:</strong></p> <p><Button Text="Parallel Property Animation" BackgroundColor="#ffff0000" x:Name="btn2" BorderColor="Black"><br /> <Button.Triggers><br /> <EventTrigger Event="Clicked" ><br /> <PA:ParellelPropertyAnimator Toggle="True"><br /> <PA:ParellelPropertyAnimator.ParallelAnimations ><br /> <PA:ParallelAnimation Target="{x:Reference btn2}"><br /> <PA:ParallelAnimation.PropertyAnimations ><br /> <PA:ColorAnimation Target="{x:Reference btn2}" StartValue="#ff0000" EndValue="#ffff00" PropertyName="BackgroundColor" Length="100"></PA:ColorAnimation><br /> <PA:ColorAnimation Target="{x:Reference btn2}" StartValue="#ffffffff" EndValue="#000000" PropertyName="TextColor" Length="100" ></PA:ColorAnimation><br /> <PA:IntegerAnimation Target="{x:Reference btn2}" StartValue="5" EndValue="25" PropertyName="CornerRadius" Length="100" ></PA:IntegerAnimation><br /> <PA:DoubleAnimation StartValue="1" EndValue="5" PropertyName="BorderWidth" Length="100" Target="{x:Reference btn2}"></PA:DoubleAnimation><br /> </PA:ParallelAnimation.PropertyAnimations><br /> </PA:ParallelAnimation><br /> </PA:ParellelPropertyAnimator.ParallelAnimations><br /> </PA:ParellelPropertyAnimator><br /> </EventTrigger><br /> </Button.Triggers><br /> </Button></p> <p><br /><img src="demo.gif" alt="" /></p> <p> </p> <p><span style="text-decoration: underline;"><strong>Complete Code of Demo Image</strong></span></p> <p> </p> <p><StackLayout VerticalOptions="CenterAndExpand" Padding="20"><br /> <Button Text="Property Animation" BackgroundColor="#ffff0000" x:Name="btn" ><br /> <Button.Triggers><br /> <EventTrigger Event="Clicked" ><br /> <PA:PropertyAnimator Toggle="True"><br /> <PA:PropertyAnimator.PropertyAnimations ><br /> <PA:ColorAnimation StartValue="#ffff0000" EndValue="#ffffff00" PropertyName="BackgroundColor" Target="{x:Reference btn}" Length="250"></PA:ColorAnimation></p> <p> </p> <p></PA:PropertyAnimator.PropertyAnimations><br /> </PA:PropertyAnimator><br /> </EventTrigger><br /> </Button.Triggers><br /> </Button></p> <p><Button Text="Parallel Property Animation" BackgroundColor="#ffff0000" x:Name="btn2" BorderColor="Black"><br /> <Button.Triggers><br /> <EventTrigger Event="Clicked" ><br /> <PA:ParellelPropertyAnimator Toggle="True"><br /> <PA:ParellelPropertyAnimator.ParallelAnimations ><br /> <PA:ParallelAnimation Target="{x:Reference btn2}"><br /> <PA:ParallelAnimation.PropertyAnimations ><br /> <PA:ColorAnimation Target="{x:Reference btn2}" StartValue="#ff0000" EndValue="#ffff00" PropertyName="BackgroundColor" Length="150"></PA:ColorAnimation><br /> <PA:ColorAnimation Target="{x:Reference btn2}" StartValue="#ffffffff" EndValue="#000000" PropertyName="TextColor" Length="150" ></PA:ColorAnimation><br /> <PA:IntegerAnimation Target="{x:Reference btn2}" StartValue="5" EndValue="25" PropertyName="CornerRadius" Length="150" ></PA:IntegerAnimation><br /> <PA:DoubleAnimation StartValue="1.0" EndValue="5.0" PropertyName="BorderWidth" Length="150" Target="{x:Reference btn2}"></PA:DoubleAnimation></p> <p><br /> </PA:ParallelAnimation.PropertyAnimations><br /> </PA:ParallelAnimation><br /> </PA:ParellelPropertyAnimator.ParallelAnimations><br /> </PA:ParellelPropertyAnimator><br /> </EventTrigger><br /> </Button.Triggers><br /> </Button><br /> <BoxView Color="Green" x:Name="bv1" HeightRequest="100" WidthRequest="200" HorizontalOptions="CenterAndExpand" ></p> <p></BoxView><br /> <Button Text="Animate BoxView (Property Animation)" x:Name="aniboxview" ><br /> <Button.Triggers><br /> <EventTrigger Event="Clicked"><br /> <PA:PropertyAnimator Toggle="True"><br /> <PA:PropertyAnimator.PropertyAnimations><br /> <PA:ColorAnimation Target="{x:Reference bv1}" StartValue="#00ff00" EndValue="#ff0000" PropertyName="Color" Length="250"></PA:ColorAnimation><br /> <PA:DoubleAnimation Target="{x:Reference bv1}" StartValue="0" EndValue="360.0" PropertyName="Rotation" Length="250"></PA:DoubleAnimation><br /> <PA:DoubleAnimation Target="{x:Reference bv1}" StartValue="1.0" EndValue="0.5" PropertyName="Scale" Length="250"></PA:DoubleAnimation><br /> <PA:CornerRadiusAnimation Target="{x:Reference bv1}" StartValue="0" EndValue="20" PropertyName="CornerRadius" Length="250"></PA:CornerRadiusAnimation><br /> </PA:PropertyAnimator.PropertyAnimations><br /> </PA:PropertyAnimator><br /> </EventTrigger><br /> </Button.Triggers><br /> </Button></p> <p><BoxView Color="Green" x:Name="bv2" HeightRequest="100" WidthRequest="200" HorizontalOptions="CenterAndExpand" ></p> <p></BoxView><br /> <Button Text="Animate BoxView (Parellel Property Animation)" x:Name="aniboxview2" ><br /> <Button.Triggers><br /> <EventTrigger Event="Clicked"><br /> <PA:ParellelPropertyAnimator Toggle="True"><br /> <PA:ParellelPropertyAnimator.ParallelAnimations><br /> <PA:ParallelAnimation Target="{x:Reference bv2}"><br /> <PA:ParallelAnimation.PropertyAnimations><br /> <PA:ColorAnimation Target="{x:Reference bv2}" StartValue="#00ff00" EndValue="#ff0000" PropertyName="Color" Length="150"></PA:ColorAnimation><br /> <PA:DoubleAnimation Target="{x:Reference bv2}" StartValue="0" EndValue="360.0" PropertyName="Rotation" Length="150"></PA:DoubleAnimation><br /> <PA:DoubleAnimation Target="{x:Reference bv2}" StartValue="1.0" EndValue="0.5" PropertyName="Scale" Length="150"></PA:DoubleAnimation><br /> <PA:CornerRadiusAnimation Target="{x:Reference bv2}" StartValue="0" EndValue="20" PropertyName="CornerRadius" Length="150"></PA:CornerRadiusAnimation></p> <p></PA:ParallelAnimation.PropertyAnimations><br /> </PA:ParallelAnimation><br /> </PA:ParellelPropertyAnimator.ParallelAnimations><br /> </PA:ParellelPropertyAnimator><br /> </EventTrigger><br /> </Button.Triggers><br /> </Button><br /> <StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand"><br /> <BoxView Color="Green" x:Name="boxview" HeightRequest="100" WidthRequest="200" HorizontalOptions="Center" ></p> <p></BoxView><br /> <Entry x:Name="entry" Text="Sample Text" HorizontalOptions="Center"></Entry></p> <p><br /> </StackLayout><br /> <Button x:Name="animul2" Text="Animate multiple (Property Animation)"><br /> <Button.Triggers><br /> <EventTrigger Event="Clicked"><br /> <PA:PropertyAnimator Toggle="True" ></p> <p><PA:PropertyAnimator.PropertyAnimations ><br /> <PA:ColorAnimation Target="{x:Reference boxview}" StartValue="#00ff00" EndValue="#ff0000" PropertyName="Color" Length="250"></PA:ColorAnimation><br /> <PA:DoubleAnimation Target="{x:Reference boxview}" StartValue="0" EndValue="360.0" PropertyName="Rotation" Length="250"></PA:DoubleAnimation><br /> <PA:DoubleAnimation Target="{x:Reference boxview}" StartValue="1.0" EndValue="0.5" PropertyName="Scale" Length="250"></PA:DoubleAnimation><br /> <PA:CornerRadiusAnimation Target="{x:Reference boxview}" StartValue="0,0,0,0" EndValue="10,20,30,20" PropertyName="CornerRadius" Length="250"></PA:CornerRadiusAnimation><br /> <PA:ColorAnimation Target="{x:Reference entry}" StartValue="#00ff00" EndValue="#ff0000" PropertyName="BackgroundColor" Length="250"></PA:ColorAnimation><br /> <PA:DoubleAnimation Target="{x:Reference entry}" StartValue="1.0" EndValue="10.0" PropertyName="CharacterSpacing" Length="250"></PA:DoubleAnimation><br /> <PA:DoubleAnimation Target="{x:Reference entry}" StartValue="1.0" EndValue="1.5" PropertyName="Scale" Length="250"></PA:DoubleAnimation><br /> </PA:PropertyAnimator.PropertyAnimations></p> <p><br /> </PA:PropertyAnimator><br /> </EventTrigger><br /> </Button.Triggers><br /> </Button></p> <p><Button x:Name="animul1" Text="Animate multiple (Parallel Animation)"><br /> <Button.Triggers><br /> <EventTrigger Event="Clicked"><br /> <PA:ParellelPropertyAnimator Toggle="True" ><br /> <PA:ParellelPropertyAnimator.ParallelAnimations><br /> <PA:ParallelAnimation Target="{x:Reference animul1}"><br /> <PA:ParallelAnimation.PropertyAnimations ><br /> <PA:ColorAnimation Target="{x:Reference boxview}" StartValue="#00ff00" EndValue="#ff0000" PropertyName="Color" Length="50"></PA:ColorAnimation><br /> <PA:DoubleAnimation Target="{x:Reference boxview}" StartValue="0" EndValue="360" PropertyName="Rotation" Length="50"></PA:DoubleAnimation><br /> <PA:DoubleAnimation Target="{x:Reference boxview}" StartValue="1" EndValue="0.5" PropertyName="Scale" Length="50"></PA:DoubleAnimation><br /> <PA:CornerRadiusAnimation Target="{x:Reference boxview}" StartValue="0,0,0,0" EndValue="10,20,30,20" PropertyName="CornerRadius" Length="50"></PA:CornerRadiusAnimation><br /> <PA:ColorAnimation Target="{x:Reference entry}" StartValue="#00ff00" EndValue="#ff0000" PropertyName="BackgroundColor" Length="50"></PA:ColorAnimation><br /> <PA:DoubleAnimation Target="{x:Reference entry}" StartValue="1" EndValue="10" PropertyName="CharacterSpacing" Length="50"></PA:DoubleAnimation><br /> <PA:DoubleAnimation Target="{x:Reference entry}" StartValue="1" EndValue="1.5" PropertyName="Scale" Length="50"></PA:DoubleAnimation><br /> </PA:ParallelAnimation.PropertyAnimations><br /> </PA:ParallelAnimation><br /> </PA:ParellelPropertyAnimator.ParallelAnimations><br /> </PA:ParellelPropertyAnimator><br /> </EventTrigger><br /> </Button.Triggers><br /> </Button></p> <p></StackLayout></p><a href="References.html">References</a>