New to Telerik UI for Xamarin? Download free 30-day trial

Button Animation on Click

Environment

Product Version 2021.3.915.1
Product Button for Xamarin Cross-Platform

Description

This article shows how to change the Telerik UI for Xamarin Button background color using animation on a Button Click event.

Solution

Button definition in XAML:

 <StackLayout>
        <telerikInput:RadButton Clicked="button_Clicked" x:Name="btn" Text="Click me"/>
</StackLayout>

and the custom code inside the Button Click Event Handler:

private async void button_Clicked(object sender, EventArgs e)
{
    StartAnimationToChangeBackgroundColor();
}

private async void StartAnimationToChangeBackgroundColor()
{
    await Task.Delay(200);
    await btn.FadeTo(0, 250);
    await Task.Delay(200);
    await btn.FadeTo(1, 250);
}
In this article