<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BasicAnimationsSample.MainPage">
<Grid Margin="{OnPlatform iOS='0,30,0,0'}">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Image x:Name="Image1" Source="bridge.jpeg" MinimumWidthRequest="100"/>
<Image x:Name="Image2" Source="bridge.jpeg" MinimumWidthRequest="100"
Grid.Row="1"/>
<Image x:Name="Image3" Source="bridge.jpeg" MinimumWidthRequest="100"
Grid.Row="2"/>
<Button Text="Single" Grid.Column="1" Clicked="SingleButton_Clicked"/>
<Button Text="Compound" Grid.Row="1" Grid.Column="1" Clicked="CompoundButton_Clicked"/>
<Button Text="Composite" Grid.Row="2" Grid.Column="1" Clicked="CompositeButton_Clicked"/>
<Button Grid.Row="3" Grid.ColumnSpan="2" Text="Cancel" Clicked="CancelButton_Clicked"/>
</Grid>
</ContentPage>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace BasicAnimationsSample
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
async void SingleButton_Clicked(System.Object sender, System.EventArgs e)
{
await Image1.RelScaleTo(2, 500);
}
async void CompoundButton_Clicked(System.Object sender, System.EventArgs e)
{
await Image2.ScaleTo(2,500);
//await Image2.RelRotateTo(30,1000);
}
async void CompositeButton_Clicked(System.Object sender, System.EventArgs e)
{
await Task.WhenAll(
Image3.RotateTo(360, 10000),
Image3.FadeTo(0,10000));
}
void CancelButton_Clicked(System.Object sender, System.EventArgs e)
{
ViewExtensions.CancelAnimations(Image1);
ViewExtensions.CancelAnimations(Image2);
ViewExtensions.CancelAnimations(Image3);
}
}
}