<AnimationExample>
<UserInterace>
<Group Spacing="10">
<Button Text="Animate" Click="AnimateClick" />
<Region Id="AnimatedRegion" Width="100" Height="100" BackgroundColor="Red" />
</Group>
</UserInterace>
<EventSystem />
</AnimationExample>
public class AnimationExample : View
{
public void AnimateClick()
{
// TODO do animations
}
}
<AnimationExample>
...
<ViewAnimation Id="MyAnimation">
</ViewAnimation>
</AnimationExample>
public class AnimationExample : View
{
public ViewAnimation MyAnimation;
public void AnimateClick()
{
MyAnimation.StartAnimation();
}
}
Method | Description |
---|---|
StartAnimation | Starts the animation. |
StopAnimation | Stops the animation. Called when the animation is not to continue anymore. Note that the animated views doesn't reset to its initial state when the animation is stopped. |
ResetAnimation | Resets the animation to its initial state but doesn't stop the animation. |
ResetAndStopAnimation | Resets the animation to its initial state and stops the animation. |
ReverseAnimation | Makes the animation run in reverse back to its initial state. |
PauseAnimation | Pauses the animation. |
ResumeAnimation | Resumes a paused animation. |
SetAnimationTarget | Changes the animation target view. |
<AnimationExample>
...
<ViewAnimation Id="MyAnimation">
<Animate Field="AnimatedRegion.Offset" From="0,0,0" To="300,0,0" Duration="750ms" />
</ViewAnimation>
</AnimationExample>
<Animate Field="AnimatedRegion.Offset" ...
<Animate ... From="0,0,0" To="300,0,0" ...
<Animate ... Duration="750ms" />
Field | Description |
---|---|
EasingFunction | Easing function to be used when interpolating between From and To values. |
AutoReset | Indicates that the animation should be reset to its startnig position when completed (false by default). |
AutoReverse | Indicates if the animation should be reversed when the animation is completed. |
Field | Path to the view field that should be animated. |
From | The starting value to be set when the animation starts. |
To | The end value to be interpolated to during animation. |
ReverseSpeed | The speed the animation should have when run in reverse (percentage of original speed). |
Duration | Duration of the animation. |
StartOffset | Delay in the interpolation of values after the animation is started. |
<AnimationExample>
...
<ViewAnimation Id="MyAnimation">
<Animate Field="AnimatedRegion.Offset" From="0,0,0" To="300,0,0" Duration="750ms"
AutoReverse="True" />
</ViewAnimation>
</AnimationExample>
<AnimationExample>
...
<ViewAnimation Id="MyAnimation">
<Animate Field="AnimatedRegion.Offset" From="0,0,0" To="300,0,0" Duration="750ms"
AutoReverse="True" EasingFunction="QuadraticEaseIn" />
</ViewAnimation>
</AnimationExample>
<AnimationExample>
...
<ViewAnimation Id="MyAnimation">
<Animate Field="AnimatedRegion.Offset" From="0,0,0" To="300,0,0" Duration="750ms"
AutoReverse="True" EasingFunction="QuadraticEaseIn" />
<Animate Field="AnimatedRegion.BackgroundColor" From="Red" To="Indigo" Duration="750ms"
AutoReverse="True" EasingFunction="QuadraticEaseIn" />
</ViewAnimation>
</AnimationExample>
<AnimationExample>
<UserInterace>
<Group Spacing="10">
<Button Id="AnimatedButton" Text="Animate" Click="AnimateClick" />
<Region Id="AnimatedRegion" Width="100" Height="100" BackgroundColor="Red" />
</Group>
</UserInterace>
<EventSystem />
<ViewAnimation Id="MyAnimation">
<Animate Field="AnimatedRegion.Offset" From="0,0,0" To="300,0,0" Duration="750ms"
AutoReverse="True" EasingFunction="QuadraticEaseIn" />
<Animate Field="AnimatedRegion.BackgroundColor" From="Red" To="Indigo" Duration="750ms"
AutoReverse="True" EasingFunction="QuadraticEaseIn" />
<Animate Field="AnimatedButton.Scale" From="1" To="0.7" Duration="250ms"
AutoReverse="True" EasingFunction="QuadraticEaseOut" />
</ViewAnimation>
</AnimationExample>
<StateAnimationExample>
<UserInterace>
<Group Spacing="10">
<Button Text="Change State" Click="ChangeState" />
<Region Width="100" Height="100" BackgroundColor="Red" />
</Group>
</UserInterace>
<EventSystem />
</StateAnimationExample>
<StateAnimationExample Left-Region.Offset="-200,0,0" Right-Region.Offset="200,0,0" >
<UserInterace>
<Group Spacing="10">
<Button Text="Change State" Click="ChangeState" />
<Region Id="Region" Width="100" Height="100" BackgroundColor="Red" />
</Group>
</UserInterace>
<EventSystem />
</StateAnimationExample>
public class StateAnimationExample : View
{
public void ChangeState()
{
if (State == "Right")
{
SetState("Left");
}
else
{
SetState("Right");
}
}
}
<StateAnimationExample Left-Region.Offset="-200,0,0" Right-Region.Offset="200,0,0" >
...
<StateAnimation From="Any" To="Right">
<Animate Field="Region.Offset" Duration="500ms" EasingFunction="QuadraticEaseOut" />
</StateAnimation>
<StateAnimation From="Any" To="Left">
<Animate Field="Region.Offset" Duration="500ms" EasingFunction="QuadraticEaseOut" />
</StateAnimation>
</StateAnimationExample>
<StateAnimation From="Any" To="Right">
<Animate Field="Region.Offset" Duration="500ms" ...
var offsetAnimator = new ViewFieldAnimator();
// set up animation
offsetAnimator.EasingFunction = EasingFunctionType.QuadraticEaseOut;
offsetAnimator.Field = "Offset"; // the field that is to be animated
offsetAnimator.From = new ElementMargin();
offsetAnimator.To = new ElementMargin(x, y, 0, 0); // x and y set during runtime
offsetAnimator.Duration = 0.2f; // duration in seconds
offsetAnimator.TargetView = MyRegion; // the view whose Offset field is to be animated
// start animation
offsetAnimator.StartAnimation();
public void Update()
{
offsetAnimator.Update();
}
Be notified when new themes, views, tutorials and updates are available